Esempio n. 1
0
    public void SetAffectedCells()
    {
        int offset = 0;

        if (this.owner == Entity.Owner.Player)
        {
            offset = GetComponent <AreaAttack>().offset + 2;
        }
        else if (this.owner == Entity.Owner.AI)
        {
            offset = GetComponent <AreaAttack>().offset - 2;
        }

        CustomPathfinding.Node node = null;
        switch (CurrentRotation)
        {
        case TROTATION.Front:
            node = this.cell.PNode.FindNodeFromThis(offset, 0);
            break;

        case TROTATION.Right:
            node = this.cell.PNode.FindNodeFromThis(0, -offset);
            break;

        case TROTATION.Back:
            node = this.cell.PNode.FindNodeFromThis(-offset, 0);
            break;

        case TROTATION.Left:
            node = this.cell.PNode.FindNodeFromThis(0, offset);
            break;
        }

        if (node != null)
        {
            nodeAffectedList = _pathfindingManager.RequestNodesAtRadius(GetComponent <AreaAttack>().areaSize, node.WorldPosition);

            for (int i = 0; i < nodeAffectedList.Count; i++)
            {
                //nodeAffectedList[i].ColorAsPossibleTurretExplosion();
                nodeAffectedList[i].cell.gameObject.transform.Find("ProjectilePlacement").gameObject.SetActive(true);
                this.CellsUnderMyAttack.Add(nodeAffectedList[i].GetOurCell());
                nodeAffectedList[i].cell.explosionBelongsTo.Add(this);
            }

            //node.ColorAsPossibleTurretExplosion();
            node.cell.gameObject.transform.Find("ProjectilePlacement").gameObject.SetActive(true);
            this.CellsUnderMyAttack.Add(node.GetOurCell());
            node.cell.explosionBelongsTo.Add(this);

            Debug.Log("el nodo en " + node.GridX + ", " + node.GridZ + " se pinta?");
        }



        for (int i = 0; i < CellsUnderMyAttack.Count; i++)
        {
            if (CellsUnderMyAttack[i].entityIn != null && CellsUnderMyAttack[i].entityIn.owner != this.owner)
            {
                CellsUnderMyAttack[i].entityIn.GetComponent <Health>().ReceiveDamage(this.GetComponent <AreaAttack>().damage);
            }
        }
    }