Beispiel #1
0
        void DeplaceTower(MoveableTower tower, SingleTowerPlacementArea area)
        {
            if (area == null)
            {
                return;
            }

            else
            {
                Vector3 targetPosition = area.transform.position;
                float   dist           = Vector3.Distance(tower.transform.position, targetPosition);

                if (dist < 0.1f)
                {
                    tower.transform.position = targetPosition;
                    IntVector2 gridPosition = area.WorldToGrid(targetPosition, dimensions);
                    area.Occupy(gridPosition, dimensions);
                    tower.currentBase = area;
                    return;
                }

                else
                {
                    tower.transform.LookAt(targetPosition, Vector3.up);
                    tower.transform.position += tower.transform.forward * speed * Time.deltaTime;
                }
            }
        }
Beispiel #2
0
        void ResetAllToFly()
        {
            towers = new List <MoveableTower>();
            towers.Clear();

            GameObject[] towersGO = GameObject.FindGameObjectsWithTag("MoveableTower");
            foreach (GameObject towerGO in towersGO)
            {
                MoveableTower tower = towerGO.GetComponent <MoveableTower>();
                tower.towerState = MoveableTower.State.Flying;

                tower.fireParticleSystem.gameObject.SetActive(false);
            }
        }
        private void Update()
        {
            if (towerState == State.Attached)
            {
                if (this == manager.previousHit && this != manager.currentHit)
                {
                    partner = manager.currentHit;

                    fireParticleSystem.gameObject.SetActive(true);
                    attackAffector.enabled = false;
                    partner.transform.GetChild(1).GetChild(0).GetComponent <AttackAffector>().enabled = false;

                    StartCoroutine(MoveParticle(fireParticleSystem.transform, partner.gameObject.transform));
                }
            }
        }
Beispiel #4
0
        private List <MoveableTower> GetCurrentTowers()
        {
            towers = new List <MoveableTower>();
            towers.Clear();

            GameObject[] towersGO = GameObject.FindGameObjectsWithTag("MoveableTower");
            foreach (GameObject towerGO in towersGO)
            {
                if (towersGO != null && towerGO.GetComponent <MoveableTower>().towerState == MoveableTower.State.Flying)
                {
                    MoveableTower tower = towerGO.GetComponent <MoveableTower>();
                    towers.Add(tower);
                }
            }

            return(towers);
        }
Beispiel #5
0
        public void AttachTowers(Raycast raycast)
        {
            if (raycast.currentHit != null && raycast.previousHit != null)
            {
                previousHit = raycast.previousHit.gameObject.GetComponent <MoveableTower>();
                currentHit  = raycast.currentHit.gameObject.GetComponent <MoveableTower>();

                if (currentHit.towerState == MoveableTower.State.Attached)
                {
                    currentHit.AttachedToFlying();
                    raycast.currentHit  = null;
                    raycast.previousHit = null;
                }
                else if (previousHit != currentHit)
                {
                    ResetAllToFly();
                    previousHit.SetAttached();
                    currentHit.SetAttached();
                }
            }
        }