public void Init(GamePos gamePos, Board board) { myPos = gamePos; this.board = board; Destroy(shootComponent.GetComponent <Collider>()); SphereCollider c = shootComponent.gameObject.AddComponent <SphereCollider>(); c.isTrigger = true; c.radius = 0.5f; }
void Update() { animation.SetActive(transform.parent.GetComponent <Tile>().isApplyingForce); if (isApplyingForce) { List <Baloon> baloons = baloonsInside.Keys.ToList(); foreach (Baloon baloon in baloons) { float time = baloonsInside[baloon]; if (time + shootDelay < Time.time) { Rigidbody r = baloon.GetComponentInChildren <Rigidbody>(); List <GamePos> freeSides = transform.parent.GetComponent <Tile>().GetFreeSides(); GamePos side = freeSides[UnityEngine.Random.Range(0, freeSides.Count)]; Vector3 forceVector = new Vector3(side.x, side.y, 0) * force; r.AddForce(forceVector); baloonsInside[baloon] = Time.time; } } } }
public void ReleasedAt(Vector2 coords) { GamePos pos = ScreenPosToGamePos(coords); board.GetTile(pos.x, pos.y).ApplyForce(false); }
public void PressedAt(Vector2 coords) { GamePos pos = ScreenPosToGamePos(coords); board.GetTile(pos.x, pos.y).ApplyForce(true); }