Assign GemSprite to BombPrefab
This commit is contained in:
@@ -20,41 +20,46 @@ MonoBehaviour:
|
|||||||
type: 3}
|
type: 3}
|
||||||
explosionPrefab: {fileID: 8904178830182364799, guid: d794be08823edd34da1790efd1739074,
|
explosionPrefab: {fileID: 8904178830182364799, guid: d794be08823edd34da1790efd1739074,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
gemSprite: {fileID: 21300000, guid: 6a4836de24a0c354f986c800d32b7c86, type: 3}
|
||||||
scoreValue: 10
|
scoreValue: 10
|
||||||
- type: 1
|
- type: 1
|
||||||
gemPrefab: {fileID: 4490600519223577409, guid: 784323496d719684cb6201b200b95864,
|
gemPrefab: {fileID: 4490600519223577409, guid: 784323496d719684cb6201b200b95864,
|
||||||
type: 3}
|
type: 3}
|
||||||
explosionPrefab: {fileID: 4157327684024108653, guid: e5bba4196a7d43441bf62bd125171449,
|
explosionPrefab: {fileID: 4157327684024108653, guid: e5bba4196a7d43441bf62bd125171449,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
gemSprite: {fileID: 21300000, guid: d184668e3ca69674d8a20a99d14eb1d2, type: 3}
|
||||||
scoreValue: 10
|
scoreValue: 10
|
||||||
- type: 2
|
- type: 2
|
||||||
gemPrefab: {fileID: 6213027626580313688, guid: 473855e3d0d3c8143836b678c9a1b8b5,
|
gemPrefab: {fileID: 6213027626580313688, guid: 473855e3d0d3c8143836b678c9a1b8b5,
|
||||||
type: 3}
|
type: 3}
|
||||||
explosionPrefab: {fileID: 5902279534240010874, guid: 072620c89288cc14e9872d103c2b2fbe,
|
explosionPrefab: {fileID: 5902279534240010874, guid: 072620c89288cc14e9872d103c2b2fbe,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
gemSprite: {fileID: 21300000, guid: 15913fd90bd479a45a568c3067a75c5d, type: 3}
|
||||||
scoreValue: 10
|
scoreValue: 10
|
||||||
- type: 3
|
- type: 3
|
||||||
gemPrefab: {fileID: 1845825807271331471, guid: 91ba2370328500d4db689dad894b1602,
|
gemPrefab: {fileID: 1845825807271331471, guid: 91ba2370328500d4db689dad894b1602,
|
||||||
type: 3}
|
type: 3}
|
||||||
explosionPrefab: {fileID: 4897855320600288343, guid: 7fcedfb0407bb5d438de37da2d61df30,
|
explosionPrefab: {fileID: 4897855320600288343, guid: 7fcedfb0407bb5d438de37da2d61df30,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
gemSprite: {fileID: 21300000, guid: 6bb7c00a68de1634cbee8574d8499804, type: 3}
|
||||||
scoreValue: 10
|
scoreValue: 10
|
||||||
- type: 4
|
- type: 4
|
||||||
gemPrefab: {fileID: 745607475630438949, guid: 93bd623174244c047af9ce43cc254c32,
|
gemPrefab: {fileID: 745607475630438949, guid: 93bd623174244c047af9ce43cc254c32,
|
||||||
type: 3}
|
type: 3}
|
||||||
explosionPrefab: {fileID: 1865769399618337668, guid: 986dd822e2e6d4b45b2a054259f1241b,
|
explosionPrefab: {fileID: 1865769399618337668, guid: 986dd822e2e6d4b45b2a054259f1241b,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
gemSprite: {fileID: 21300000, guid: fa67839330996764683a123cb35a1ea8, type: 3}
|
||||||
scoreValue: 10
|
scoreValue: 10
|
||||||
- type: 5
|
- type: 5
|
||||||
gemPrefab: {fileID: 5652386976359944012, guid: aa0291e650b382941875040db9e8a232,
|
gemPrefab: {fileID: 5652386976359944012, guid: aa0291e650b382941875040db9e8a232,
|
||||||
type: 3}
|
type: 3}
|
||||||
explosionPrefab: {fileID: 8968486364681163996, guid: 05c754e3d4f9fd349ac1def58d17670f,
|
explosionPrefab: {fileID: 8968486364681163996, guid: 05c754e3d4f9fd349ac1def58d17670f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
gemSprite: {fileID: 21300000, guid: d1c82e015b38d4448bc1ba5e3eff90fa, type: 3}
|
||||||
scoreValue: 10
|
scoreValue: 10
|
||||||
width: 7
|
width: 7
|
||||||
height: 7
|
height: 7
|
||||||
bombDelay: 2
|
bombDelay: 2
|
||||||
bombSelfDelay: 1
|
|
||||||
bombRadius: 2
|
bombRadius: 2
|
||||||
dropHeight: 2
|
dropHeight: 2
|
||||||
gemSpeed: 0.00625
|
gemSpeed: 0.00625
|
||||||
|
|||||||
@@ -1,5 +1,89 @@
|
|||||||
%YAML 1.1
|
%YAML 1.1
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &1833905315907890653
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6673945018952926847}
|
||||||
|
- component: {fileID: 8819328447377349610}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Square
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &6673945018952926847
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1833905315907890653}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: -0.3, y: -0.4, z: 0}
|
||||||
|
m_LocalScale: {x: 0.4, y: 0.4, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1210587634127288451}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!212 &8819328447377349610
|
||||||
|
SpriteRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1833905315907890653}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 0
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: -1529445301
|
||||||
|
m_SortingLayer: 1
|
||||||
|
m_SortingOrder: 1
|
||||||
|
m_Sprite: {fileID: 21300000, guid: 6a4836de24a0c354f986c800d32b7c86, type: 3}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_FlipX: 0
|
||||||
|
m_FlipY: 0
|
||||||
|
m_DrawMode: 0
|
||||||
|
m_Size: {x: 1, y: 1}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_SpriteSortPoint: 0
|
||||||
--- !u!1001 &8839428272799928612
|
--- !u!1001 &8839428272799928612
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -29,6 +113,11 @@ PrefabInstance:
|
|||||||
propertyPath: m_SpriteTilingProperty.oldSize.y
|
propertyPath: m_SpriteTilingProperty.oldSize.y
|
||||||
value: 1
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 3808538059049426536, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
|
type: 3}
|
||||||
|
propertyPath: childSpriteRenderer
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 8819328447377349610}
|
||||||
- target: {fileID: 7667143225876670874, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
- target: {fileID: 7667143225876670874, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
type: 3}
|
type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
@@ -129,6 +218,16 @@ PrefabInstance:
|
|||||||
m_RemovedComponents:
|
m_RemovedComponents:
|
||||||
- {fileID: -7932498854989450506, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
- {fileID: -7932498854989450506, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
|
type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 6673945018952926847}
|
||||||
m_AddedComponents: []
|
m_AddedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec, type: 3}
|
||||||
|
--- !u!4 &1210587634127288451 stripped
|
||||||
|
Transform:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 7667143225876670887, guid: 724e93e48c6cc0b4ab3d44e5ea34f2ec,
|
||||||
|
type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 8839428272799928612}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Enums;
|
using Enums;
|
||||||
|
using Structs;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Services {
|
namespace Services {
|
||||||
@@ -14,10 +15,10 @@ namespace Services {
|
|||||||
private GemType colorType;
|
private GemType colorType;
|
||||||
public GemType MatchColor => this.type == GemType.Bomb ? this.colorType : this.type;
|
public GemType MatchColor => this.type == GemType.Bomb ? this.colorType : this.type;
|
||||||
|
|
||||||
public Gem(GemType type, Vector2Int position, int scoreValue, GemType? colorType = null) {
|
public Gem(GemType type, Vector2Int position, GemTypeValues gemValue, GemType? colorType = null) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.scoreValue = scoreValue;
|
this.scoreValue = gemValue.scoreValue;
|
||||||
|
|
||||||
this.colorType = colorType ?? type;
|
this.colorType = colorType ?? type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,11 +83,12 @@ namespace Services {
|
|||||||
GemView gemView = this.objectPool.Get(gemType, position, this.gameVariables.dropHeight);
|
GemView gemView = this.objectPool.Get(gemType, position, this.gameVariables.dropHeight);
|
||||||
gemView.name = "Gem - " + position.x + ", " + position.y + ' ' + gemType;
|
gemView.name = "Gem - " + position.x + ", " + position.y + ' ' + gemType;
|
||||||
|
|
||||||
// If we randomly spawned a bomb, give it a random color group (so it can match by color).
|
GemTypeValues gemValue = GemUtils.GetGemValues(gemType, this.gameVariables.gemsPrefabs);
|
||||||
int scoreValue = GemUtils.GetGemValues(gemType, this.gameVariables.gemsPrefabs).scoreValue;
|
|
||||||
Gem gem = new Gem(gemType, position, scoreValue);
|
|
||||||
|
|
||||||
gemView.Bind(gem);
|
// If we randomly spawned a bomb, give it a random color group (so it can match by color).
|
||||||
|
Gem gem = new Gem(gemType, position, gemValue);
|
||||||
|
|
||||||
|
gemView.Bind(gem, gemValue);
|
||||||
|
|
||||||
this.gemPresenters.Add(new GemPresenter(gem, gemView));
|
this.gemPresenters.Add(new GemPresenter(gem, gemView));
|
||||||
SetGem(new Vector2Int(position.x, position.y), gem);
|
SetGem(new Vector2Int(position.x, position.y), gem);
|
||||||
@@ -100,9 +101,10 @@ namespace Services {
|
|||||||
GemView gemView = this.objectPool.Get(GemType.Bomb, position, 0);
|
GemView gemView = this.objectPool.Get(GemType.Bomb, position, 0);
|
||||||
gemView.name = "Bomb - " + position.x + ", " + position.y + ' ' + GemType.Bomb;
|
gemView.name = "Bomb - " + position.x + ", " + position.y + ' ' + GemType.Bomb;
|
||||||
|
|
||||||
int scoreValue = GemUtils.GetGemValues(color, this.gameVariables.gemsPrefabs).scoreValue;
|
GemTypeValues gemValue = GemUtils.GetGemValues(color, this.gameVariables.gemsPrefabs);
|
||||||
Gem bombGem = new Gem(GemType.Bomb, position, scoreValue, color);
|
|
||||||
gemView.Bind(bombGem, isBomb: true);
|
Gem bombGem = new Gem(GemType.Bomb, position, gemValue, color);
|
||||||
|
gemView.Bind(bombGem, gemValue, isBomb: true);
|
||||||
|
|
||||||
this.gemPresenters.Add(new GemPresenter(bombGem, gemView));
|
this.gemPresenters.Add(new GemPresenter(bombGem, gemView));
|
||||||
SetGem(position, bombGem);
|
SetGem(position, bombGem);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace Structs {
|
|||||||
public GemType type;
|
public GemType type;
|
||||||
public GemView gemPrefab;
|
public GemView gemPrefab;
|
||||||
public GameObject explosionPrefab;
|
public GameObject explosionPrefab;
|
||||||
|
public Sprite gemSprite;
|
||||||
public int scoreValue;
|
public int scoreValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,45 +2,47 @@ using System.Threading;
|
|||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using Enums;
|
using Enums;
|
||||||
using Services;
|
using Services;
|
||||||
|
using Structs;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Utils;
|
using Utils;
|
||||||
|
|
||||||
namespace Views {
|
namespace Views {
|
||||||
public class GemView : MonoBehaviour {
|
public class GemView : MonoBehaviour {
|
||||||
|
[SerializeField]
|
||||||
|
private SpriteRenderer childSpriteRenderer;
|
||||||
|
|
||||||
private Gem gem;
|
private Gem gem;
|
||||||
public Gem Gem => this.gem;
|
public Gem Gem => this.gem;
|
||||||
|
|
||||||
private SpriteRenderer spriteRenderer;
|
|
||||||
|
|
||||||
private bool isFalling;
|
private bool isFalling;
|
||||||
private const float SPAWN_SCALE_FROM = 0f;
|
private const float SPAWN_SCALE_FROM = 0f;
|
||||||
private const float SPAWN_SCALE_DURATION = 0.12f;
|
private const float SPAWN_SCALE_DURATION = 0.12f;
|
||||||
|
|
||||||
private CancellationTokenSource spawnScaleCts;
|
private CancellationTokenSource spawnScaleCts;
|
||||||
|
|
||||||
public void Bind(Gem gem, bool isBomb = false) {
|
public void Bind(Gem gem, GemTypeValues gemvalue, bool isBomb = false) {
|
||||||
this.gem = gem;
|
this.gem = gem;
|
||||||
this.gameObject.SetActive(true);
|
this.gameObject.SetActive(true);
|
||||||
|
|
||||||
SetupGem(isBomb);
|
SetupGem(isBomb, gemvalue.gemSprite);
|
||||||
PlaySpawnScale();
|
PlaySpawnScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupGem(bool isBomb) {
|
private void SetupGem(bool isBomb, Sprite gemSprite = null) {
|
||||||
this.spriteRenderer ??= GetComponent<SpriteRenderer>();
|
if (!isBomb)
|
||||||
|
return;
|
||||||
|
|
||||||
if (isBomb) {
|
if (this.childSpriteRenderer is null)
|
||||||
this.spriteRenderer.color = this.gem.MatchColor switch {
|
return;
|
||||||
GemType.Blue => Color.blue,
|
|
||||||
GemType.Green => Color.green,
|
if (gemSprite != null) {
|
||||||
GemType.Red => Color.red,
|
this.childSpriteRenderer.enabled = true;
|
||||||
GemType.Yellow => Color.yellow,
|
this.childSpriteRenderer.sprite = gemSprite;
|
||||||
GemType.Purple => Color.magenta,
|
|
||||||
_ => this.spriteRenderer.color
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
this.spriteRenderer.color = Color.white;
|
this.childSpriteRenderer.enabled = false;
|
||||||
|
this.childSpriteRenderer.color = Color.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unbind() {
|
public void Unbind() {
|
||||||
|
|||||||
Reference in New Issue
Block a user