예제 #1
0
 /// <summary>
 /// Caches the Attack Affector if necessary
 /// </summary>
 protected override void LazyLoad()
 {
     base.LazyLoad();
     if (m_AttackAffector == null)
     {
         m_AttackAffector = GetComponent <AttackAffector>();
     }
 }
예제 #2
0
    public override void SetupEffect()
    {
        AttackAffector attack = activeUnit.projectileHandler as AttackAffector;

        if (attack && attack.damagerProjectile is Damager)
        {
            attack.HasDamaged += Projectile_HasDamagedTarget;
        }
    }
 private void Start()
 {
     towerState             = State.Flying;
     attackAffector         = transform.GetChild(1).GetChild(0).GetComponent <AttackAffector>();
     attackAffector.enabled = true;
     fireParticleSystem.gameObject.SetActive(false);
     fireParticleSystem.transform.position = new Vector3(0, 0, 0);
     manager = FindObjectOfType <MoveableTowersManager>();
 }
예제 #4
0
    public override void SetupEffect()
    {
        AttackAffector attack = activeUnit.projectileHandler as AttackAffector;

        if (attack)
        {
            attack.BeforeFireProjectile += Attacker_BeforeFireProjectile;
            attack.AfterFireProjectile  += Attacker_AfterFireProjectile;
        }
    }
예제 #5
0
 /// <summary>
 /// A lazy way to ensure that <see cref="m_Agent"/> will not be null
 /// </summary>
 protected virtual void LazyLoad()
 {
     if (m_Unit == null)
     {
         m_Unit = GetComponent <Unit>();
     }
     if (m_Affector == null)
     {
         m_Affector = GetComponent <AttackAffector>();
     }
 }
예제 #6
0
        private void Preparation()
        {
            towers       = GetCurrentTowers();
            nearestAgent = GetNearestAgent();

            possibleBases.Clear();

            foreach (SingleTowerPlacementArea area in allBases)
            {
                area.isSelected = false;
            }
            foreach (MoveableTower tower in towers)
            {
                AttackAffector attackAffector = tower.gameObject.transform.GetChild(1).GetChild(0).GetComponent <AttackAffector>();
                attackAffector.enabled = true;
                SingleTowerPlacementArea selectedBase = SearchNearestBase(nearestAgent);
                IntVector2 gridPosition = selectedBase.WorldToGrid(selectedBase.transform.position, dimensions);
                selectedBase.Clear(gridPosition, dimensions);
                possibleBases.Add(selectedBase);
                tower.currentBase.Clear(gridPosition, dimensions);
                tower.currentBase = null;
            }
        }
예제 #7
0
    void FixedUpdate()
    {
        // The towers will be updating their positions and scale in their own update functions.
        // The following section of code will let's the metadata system know that this
        // is the particular metadata we want to send down to the clients.

        //dyanmically get the towers that exist. Update the tower array

        GameObject[] towersObj = GameObject.FindGameObjectsWithTag("Tower");
        towers = new Tower[towersObj.Length];

        // The towers will be updating their positions and scale in their own update functions.
        // The following section of code will let's the metadata system know that this
        // is the particular metadata we want to send down to the clients.
        metadataUpdateParms.items = new ServerTowerInformation[towers.Length];


        for (var i = 0; i < towersObj.Length; i++)
        {
            towers[i] = towersObj[i].GetComponent <Tower>();
        }

        for (var k = 0; k < towersObj.Length; k++)
        {
            //var screenPos = APG.Helper.ScreenPosition(mainCamera, towers[k]);

            /* use the getcollider function and then get the 8 coords to enter into the
             * worldtoscreenfunc and then get the top left (max x and min y)
             * Also get the bottom right corner and pass into the for loop in line 85.
             * Scale is abs(bottomright-topleft)
             */

            Collider col = towers[k].getCollider();

            Vector2 wFrontTopLeft     = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.min.x, col.bounds.max.y, col.bounds.min.z));
            Vector2 wFrontTopRight    = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.max.x, col.bounds.max.y, col.bounds.min.z));
            Vector2 wFrontBottomRight = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.max.x, col.bounds.min.y, col.bounds.min.z));
            Vector2 wFrontBottomLeft  = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.min.x, col.bounds.min.y, col.bounds.min.z));
            Vector2 wBackTopLeft      = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.min.x, col.bounds.max.y, col.bounds.max.z));
            Vector2 wBackTopRight     = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.max.x, col.bounds.max.y, col.bounds.max.z));
            Vector2 wBackBottomRight  = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.max.x, col.bounds.min.y, col.bounds.max.z));
            Vector2 wBackBottomLeft   = APG.Helper.ScreenPosition(mainCamera, new Vector3(col.bounds.min.x, col.bounds.min.y, col.bounds.max.z));

            /* Get Max and Min bounding box positions */

            var topLeftX = Mathf.Min(wFrontTopLeft.x, wFrontTopRight.x, wFrontBottomRight.x
                                     , wFrontBottomLeft.x, wBackTopLeft.x, wBackTopRight.x
                                     , wBackBottomRight.x, wBackBottomLeft.x);

            var topLeftY = Mathf.Max(wFrontTopLeft.y, wFrontTopRight.y, wFrontBottomRight.y
                                     , wFrontBottomLeft.y, wBackTopLeft.y, wBackTopRight.y
                                     , wBackBottomRight.y, wBackBottomLeft.y);

            var bottomRightX = Mathf.Max(wFrontTopLeft.x, wFrontTopRight.x, wFrontBottomRight.x
                                         , wFrontBottomLeft.x, wBackTopLeft.x, wBackTopRight.x
                                         , wBackBottomRight.x, wBackBottomLeft.x);

            var bottomRightY = Mathf.Min(wFrontTopLeft.y, wFrontTopRight.y, wFrontBottomRight.y
                                         , wFrontBottomLeft.y, wBackTopLeft.y, wBackTopRight.y
                                         , wBackBottomRight.y, wBackBottomLeft.y);


            metadataUpdateParms.items[k].x      = (int)topLeftX;
            metadataUpdateParms.items[k].y      = (int)topLeftY;
            metadataUpdateParms.items[k].scaleX = (int)Mathf.Abs(bottomRightX - topLeftX);
            metadataUpdateParms.items[k].scaleY = (int)Mathf.Abs(bottomRightY - topLeftY);

            /* Get Tower Information */
            TowerLevelData data   = towers[k].GetComponentInChildren <TowerLevel>().levelData;
            AttackAffector attack = towers[k].GetComponentInChildren <AttackAffector>();
            metadataUpdateParms.items[k].attack   = attack.projectile.GetComponent <Damager>().damage;
            metadataUpdateParms.items[k].fireRate = attack.fireRate;
            Targetter target = towers[k].GetComponentInChildren <Targetter>();
            metadataUpdateParms.items[k].radius = target.effectRadius;

            metadataUpdateParms.items[k].name = towers[k].towerName;
        }
    }