예제 #1
0
        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;
                    }
                }
            }
        }
예제 #3
0
        public void ReleasedAt(Vector2 coords)
        {
            GamePos pos = ScreenPosToGamePos(coords);

            board.GetTile(pos.x, pos.y).ApplyForce(false);
        }
예제 #4
0
        public void PressedAt(Vector2 coords)
        {
            GamePos pos = ScreenPosToGamePos(coords);

            board.GetTile(pos.x, pos.y).ApplyForce(true);
        }