Esempio n. 1
0
 public void Start()
 {
     turn = FindObjectOfType <TurnManager>();
     transform.position = grid.GetWorldPosition(x, y);
     maxRangeHzPlayer2  = x;
     maxRangeVtPlayer2  = y;
 }
 public void Start()
 {
     turn = FindObjectOfType <TurnManager>();
     transform.position = grid.GetWorldPosition(x, y);
     maxRangeHzUtility1 = x;
     maxRangeVtUtility1 = y;
     turn.isTurn        = true;
 }
 public void Start()
 {
     selectionP2           = FindObjectOfType <SelectControllerP2>();
     turn                  = FindObjectOfType <TurnManager>();
     transform.position    = grid.GetWorldPosition(x, y);
     maxRangeHzTankPlayer2 = x;
     maxRangeVtTankPlayer2 = y;
 }
 public void Start()
 {
     selection               = FindObjectOfType <SelectionController>();
     turn                    = FindObjectOfType <TurnManager>();
     transform.position      = grid.GetWorldPosition(x, y);
     maxRangeHzHealerPlayer1 = x;
     maxRangeVtHealerPlayer1 = y;
     turn.isTurn             = true;
 }
Esempio n. 5
0
 //scelgo direzione dove lanciare l'abilita
 public void SetDirectionAbility()
 {
     SetRange();
     //destra
     if (Input.GetKeyDown(KeyCode.D) && rangeHz >= -2 && isAbility == true)
     {
         tester.x++;
         transform.position       = grid.GetWorldPosition(tester.x, tester.y);
         tester.maxRangeHzPlayer1 = tester.x;
         SetRange();
         lm.lifePlayer2 -= att;
         turn.isTurn     = false;
         isAbility       = false;
         //riabilito input controller per i movimenti(wasd)
         input.enabled = true;
     }
     //sinistra
     if (Input.GetKeyDown(KeyCode.A) && rangeHz <= 2 && isAbility == true)
     {
         tester.x--;
         transform.position       = grid.GetWorldPosition(tester.x, tester.y);
         tester.maxRangeHzPlayer1 = tester.x;
         SetRange();
         lm.lifePlayer2 -= att;
         turn.isTurn     = false;
         isAbility       = false;
         //riabilito input controller per i movimenti(wasd)
         input.enabled = true;
     }
     //sopra
     if (Input.GetKeyDown(KeyCode.W) && rangeVt >= -2 && isAbility == true)
     {
         tester.y++;
         transform.position       = grid.GetWorldPosition(tester.x, tester.y);
         tester.maxRangeVtPlayer1 = tester.y;
         SetRange();
         lm.lifePlayer2 -= att;
         turn.isTurn     = false;
         isAbility       = false;
         //riabilito input controller per i movimenti(wasd)
         input.enabled = true;
     }
     //sotto
     if (Input.GetKeyDown(KeyCode.S) && rangeVt <= 2 && isAbility == true)
     {
         tester.y--;
         transform.position       = grid.GetWorldPosition(tester.x, tester.y);
         tester.maxRangeVtPlayer1 = tester.y;
         SetRange();
         lm.lifePlayer2 -= att;
         turn.isTurn     = false;
         isAbility       = false;
         //riabilito input controller per i movimenti(wasd)
         input.enabled = true;
     }
 }
 void Start()
 {
     Text               = FindObjectOfType <HudManagerTest>();
     turn               = FindObjectOfType <TurnManager>();
     tankP2             = FindObjectOfType <PositionTester2>();
     healerP2           = FindObjectOfType <PositionHealer2>();
     contSelectionP2    = 0;
     transform.position = grid.GetWorldPosition(x, y);
     gameObject.GetComponent <MeshRenderer>().enabled = false;
 }
Esempio n. 7
0
 // Use this for initialization
 void Start()
 {
     contProv                = 1;
     timer                   = 0.5f;
     lm                      = FindObjectOfType <LifeManager>();
     selection               = FindObjectOfType <SelectControllerP2>();
     turn                    = FindObjectOfType <TurnManager>();
     transform.position      = grid.GetWorldPosition(x, y);
     maxRangeHzDealerPlayer2 = x;
     maxRangeVtDealerPlayer2 = y;
     turn.isTurn             = true;
     contMp                  = 4;
     att                     = FindObjectOfType <AttackBaseDealer2>();
     ab                      = FindObjectOfType <AbilityDealer2>();
 }
Esempio n. 8
0
 // Update is called once per frame
 void Update()
 {
     if (grid)
     {
         transform.position = grid.GetWorldPosition(x, y);
     }
 }
 public void Start()
 {
     lm                      = FindObjectOfType <LifeManager>();
     timer                   = 0.5f;
     contMp                  = 4;
     selectionP2             = FindObjectOfType <SelectControllerP2>();
     turn                    = FindObjectOfType <TurnManager>();
     transform.position      = grid.GetWorldPosition(x, y);
     maxRangeHzHealerPlayer2 = x;
     maxRangeVtHealerPlayer2 = y;
     att                     = FindObjectOfType <AttackBaseHealer2>();
     ab                      = FindObjectOfType <AbilityHealer2>();
 }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     timer              = 0.5f;
     myTurn             = false;
     lm                 = FindObjectOfType <LifeManager>();
     selection          = FindObjectOfType <SelectionController>();
     turn               = FindObjectOfType <TurnManager>();
     transform.position = grid.GetWorldPosition(x, y);
     Debug.Log("X: " + x + "Y: " + y);
     turn.isTurn = true;
     contMp      = 4;
     att         = FindObjectOfType <AttackBaseDealer>();
     ab          = FindObjectOfType <AbilityDealer>();
 }
Esempio n. 11
0
 // Use this for initialization
 void Start()
 {
     timer                    = 0.5f;
     myTurn                   = false;
     lm                       = FindObjectOfType <LifeManager>();
     selection                = FindObjectOfType <SelectionController>();
     turn                     = FindObjectOfType <TurnManager>();
     transform.position       = grid.GetWorldPosition(x, y);
     maxRangeHzUtilityPlayer1 = x;
     maxRangeVtUtilityPlayer1 = y;
     turn.isTurn              = true;
     contMp                   = 4;
     att                      = FindObjectOfType <AttackBaseUtility>();
     ab                       = FindObjectOfType <AbilityUtility>();
 }
    //public float random;

    public void Start()
    {
        //myTurn = false;
        // random = 2f;
        lm                    = FindObjectOfType <LifeManager>();
        timer                 = 0.5f;
        selection             = FindObjectOfType <SelectionController>();
        turn                  = FindObjectOfType <TurnManager>();
        transform.position    = grid.GetWorldPosition(x, y);
        maxRangeHzTankPlayer1 = x;
        maxRangeVtTankPlayer1 = y;
        //turn.isTurn = true;
        contMp = 3;
        att    = FindObjectOfType <AttackBase1>();
        ab     = FindObjectOfType <AbilityTank>();
    }
    public void Start()
    {
        prova                   = 5;
        myTurn                  = false;
        lm                      = FindObjectOfType <LifeManager>();
        timer                   = 0.5f;
        contMp                  = 4;
        selection               = FindObjectOfType <SelectionController>();
        turn                    = FindObjectOfType <TurnManager>();
        transform.position      = grid.GetWorldPosition(x, y);
        maxRangeHzHealerPlayer1 = x;
        maxRangeVtHealerPlayer1 = y;
        turn.isTurn             = true;
        att                     = GetComponent <AttackBaseHealer>();

        ab = FindObjectOfType <AbilityHealer>();
    }
Esempio n. 14
0
 void Start()
 {
     isTankUsable       = true;
     isHealerUsable     = true;
     isUtilityUsable    = true;
     isDealerUsable     = true;
     duration           = 0.5f;
     dealerP1           = FindObjectOfType <PositionDealer>();
     utilityP1          = FindObjectOfType <PositionUtility>();
     Text               = FindObjectOfType <HudManagerTest>();
     turn               = FindObjectOfType <TurnManager>();
     tankP1             = FindObjectOfType <PositionTester>();
     healerP1           = FindObjectOfType <PositionHealer>();
     contSelectionP1    = 0;
     transform.position = grid.GetWorldPosition(x, y);
     gameObject.GetComponent <MeshRenderer>().enabled = false;
     selector.SetActive(false);
     inputPad = FindObjectOfType <InputTester>();
 }
 // Use this for initialization
 void Start()
 {
     speed    = 100;
     cont     = 0;
     x        = dealerP1.x;
     y        = dealerP1.y;
     dealerP1 = FindObjectOfType <PositionDealer>();
     // controllare
     selector.transform.position = grid.GetWorldPosition(dealerP1.x, dealerP1.y);
     transform.position          = grid.GetWorldPosition(dealerP1.x, dealerP1.y);
     selector.transform.GetChild(0).gameObject.SetActive(false);
     selection = Object.FindObjectOfType <SelectionController>().GetComponent <SelectionController>();
     Debug.Log("Selection: " + selection);
     utility      = FindObjectOfType <PositionUtility>();
     tankP2       = FindObjectOfType <PositionTester2>();
     healerP2     = FindObjectOfType <PositionHealer2>();
     utilityP2    = FindObjectOfType <PositionUtility2>();
     dealerP2     = FindObjectOfType <PositionDealer2>();
     lm           = FindObjectOfType <LifeManager>();
     turn         = FindObjectOfType <TurnManager>();
     isAbility    = false;
     CounterA     = 2;
     CounterTurnA = 0;
 }
    // Use this for initialization
    void Start()
    {
        speed = 100;
        cont  = 0;
        x     = dealerP2.x;
        y     = dealerP2.y;
        // controllare
        selector.transform.position = grid.GetWorldPosition(dealerP2.x, dealerP2.y);
        transform.position          = grid.GetWorldPosition(dealerP2.x, dealerP2.y);
        selector.transform.GetChild(0).gameObject.SetActive(false);
        selectionP2 = Object.FindObjectOfType <SelectControllerP2>().GetComponent <SelectControllerP2>();

        dealerP2 = FindObjectOfType <PositionDealer2>();

        turn         = FindObjectOfType <TurnManager>();
        isAbility    = false;
        CounterA     = 2;
        CounterTurnA = 0;
    }
Esempio n. 17
0
    IEnumerator SetDirectionAttackBase()
    {
        //SetRange();
        //tank destra
        if (Input.GetKeyDown(KeyCode.Return) && isAbility == true && tankP2.isUnitEnemie == true)
        {
            if (tankP2.hit.transform.gameObject.GetComponent <PositionTester>())
            {
                DamageTankP1();
                if (OnAbility != null)
                {
                    OnAbility();
                }
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (isAttUp == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x++, tankP2.y);
                }
                else if (isAttDown == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
                }
                else if (isAttRight == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
                }
                else if (isAttLeft == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y++);
                }
                selectionP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                selectionP2.transform.DOMoveZ(tankP2.y, duration).SetAutoKill(false);
                selectionP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y);
                selectionP2.x = tankP2.x;
                selectionP2.y = tankP2.y;
                tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                //tankP1.transform.DOShakePosition(2f, strength, vibrato);
                tankP2.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank2 = false;
                GameManager.singleton.sc2.isTankUsable2 = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");
                Counter = 0;
            }
            else if (tankP2.hit.transform.gameObject.GetComponent <PositionHealer>())
            {
                DamageHealerP1();
                if (OnAbility != null)
                {
                    OnAbility();
                }
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (isAttUp == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x++, tankP2.y);
                }
                else if (isAttDown == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
                }
                else if (isAttRight == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
                }
                else if (isAttLeft == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y++);
                }
                selectionP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                selectionP2.transform.DOMoveZ(tankP2.y, duration).SetAutoKill(false);
                selectionP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y);
                selectionP2.x = tankP2.x;
                selectionP2.y = tankP2.y;
                tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                //healerP1.transform.DOShakePosition(2f, strength, vibrato);
                tankP2.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank2 = false;
                GameManager.singleton.sc2.isTankUsable2 = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");
                Counter = 0;
            }
            else if (tankP2.hit.transform.gameObject.GetComponent <PositionUtility>())
            {
                DamageUtilityP1();
                if (OnAbility != null)
                {
                    OnAbility();
                }
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (isAttUp == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x++, tankP2.y);
                }
                else if (isAttDown == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
                }
                else if (isAttRight == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
                }
                else if (isAttLeft == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y++);
                }
                selectionP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                selectionP2.transform.DOMoveZ(tankP2.y, duration).SetAutoKill(false);
                selectionP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y);
                selectionP2.x = tankP2.x;
                selectionP2.y = tankP2.y;
                tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                //utilityP1.transform.DOShakePosition(2f, strength, vibrato);
                tankP2.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank2 = false;
                GameManager.singleton.sc2.isTankUsable2 = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");
                Counter = 0;
            }
            else if (tankP2.hit.transform.gameObject.GetComponent <PositionDealer>())
            {
                DamageDealerP1();
                if (OnAbility != null)
                {
                    OnAbility();
                }
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (isAttUp == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x++, tankP2.y);
                }
                else if (isAttDown == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
                }
                else if (isAttRight == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
                }
                else if (isAttLeft == true)
                {
                    tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y++);
                }
                selectionP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                selectionP2.transform.DOMoveZ(tankP2.y, duration).SetAutoKill(false);
                selectionP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y);
                selectionP2.x = tankP2.x;
                selectionP2.y = tankP2.y;
                tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
                //dealerP1.transform.DOShakePosition(2f, strength, vibrato);
                tankP2.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank2 = false;
                GameManager.singleton.sc2.isTankUsable2 = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");
                Counter = 0;
            }
        }

        //tanke sinistra

        /*if (Input.GetKeyDown(KeyCode.I) && isAbility == true && isAttDown == true && tankP2.isUnitEnemie == true)
         * {
         *
         *
         *  if (tankP2.hit.transform.gameObject.GetComponent<PositionTester>())
         *  {
         *
         *      DamageTankP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      tankP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionHealer>())
         *  {
         *      DamageHealerP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      healerP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionUtility>())
         *  {
         *      DamageUtilityP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      utilityP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionDealer>())
         *  {
         *      DamageDealerP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x--, tankP2.y);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      dealerP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         * }
         *
         * //tank sopra
         * if (Input.GetKeyDown(KeyCode.L) && isAbility == true && isAttLeft == true && tankP2.isUnitEnemie == true)
         * {
         *
         *  if (tankP2.hit.transform.gameObject.GetComponent<PositionTester>())
         *  {
         *      DamageTankP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y++);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      tankP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionHealer>())
         *  {
         *      DamageHealerP1();
         *
         *
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      healerP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionUtility>())
         *  {
         *      DamageUtilityP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y++);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      utilityP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionDealer>())
         *  {
         *      DamageDealerP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y++);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      dealerP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *
         * }
         *
         * // healer sotto
         * if (Input.GetKeyDown(KeyCode.J) && isAbility == true && isAttRight == true && tankP2.isUnitEnemie == true)
         * {
         *
         *  if (tankP2.hit.transform.gameObject.GetComponent<PositionTester>())
         *  {
         *      DamageTankP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      tankP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionHealer>())
         *  {
         *      DamageHealerP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      healerP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionUtility>())
         *  {
         *      DamageUtilityP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      utilityP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         *  else if (tankP2.hit.transform.gameObject.GetComponent<PositionDealer>())
         *  {
         *      DamageDealerP1();
         *      tankP2.transform.position = grid.GetWorldPosition(tankP2.x, tankP2.y--);
         *      tankP2.transform.DOMoveX(tankP2.x, duration).SetAutoKill(false);
         *      dealerP1.transform.DOShakePosition(2f, strength, vibrato);
         *      yield return new WaitForSeconds(2f);
         *      turn.isTurn = true;
         *      Counter = 0;
         *  }
         * }*/
    }
 public void GoToLeft()
 {
     x--;
     transform.position = grid.GetWorldPosition(x, y);
 }
Esempio n. 19
0
    //scelgo direzione dove lanciare l'abilita
    public void SetDirectionAbility()
    {
        SetRange();
        //destra TankP2 positivo
        if (Input.GetKeyDown(KeyCode.D) && rangeHzTank <= 2 && tankP2.y == tank.y && isAbility == true)
        {
            if (rangeHzTank < rangeHzHealer)
            {
                tankP2.x++;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeHzTankPlayer2 = tankP2.x;
                SetRange();
                lm.lifeTank -= att;
                turn.isTurn  = true;
                isAbility    = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }
        // destra HealerP2
        if (Input.GetKeyDown(KeyCode.D) && rangeHzHealer <= 2 && tankP2.y == healerP1.y && isAbility == true)
        {
            if (rangeHzHealer < rangeHzTank)
            {
                tankP2.x++;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeHzTankPlayer2 = tankP2.x;
                SetRange();
                lm.lifeHealer -= att;
                turn.isTurn    = true;
                isAbility      = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }
        //sinistra tank
        if (Input.GetKeyDown(KeyCode.A) && rangeHzTank >= -2 && tankP2.y == tank.y && isAbility == true)
        {
            if (rangeHzTank > rangeHzHealer)
            {
                tankP2.x++;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeHzTankPlayer2 = tankP2.x;
                SetRange();
                lm.lifeTank -= att;
                turn.isTurn  = true;
                isAbility    = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }
        // sinistra healer
        if (Input.GetKeyDown(KeyCode.A) && rangeHzHealer >= -2 && tankP2.y == healerP1.y && isAbility == true)
        {
            if (rangeHzHealer > rangeHzTank)
            {
                tankP2.x--;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeHzTankPlayer2 = tankP2.x;
                SetRange();
                lm.lifeHealer -= att;
                turn.isTurn    = true;
                isAbility      = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }
        //sopra tank
        if (Input.GetKeyDown(KeyCode.W) && rangeVtTank <= 2 && tankP2.y == tank.y && isAbility == true)
        {
            if (rangeVtTank < rangeVtHealer)
            {
                tankP2.y++;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeVtTankPlayer2 = tankP2.y;
                SetRange();
                lm.lifeTank -= att;
                turn.isTurn  = true;
                isAbility    = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }

        //sopra healer

        if (Input.GetKeyDown(KeyCode.W) && rangeVtHealer <= 2 && tankP2.y == healerP1.y && isAbility == true)
        {
            if (rangeVtHealer < rangeVtTank)
            {
                tankP2.y++;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeVtTankPlayer2 = tankP2.y;
                SetRange();
                lm.lifeHealer -= att;
                turn.isTurn    = true;
                isAbility      = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }


        // sotto tank
        if (Input.GetKeyDown(KeyCode.S) && rangeVtTank >= -2 && tankP2.y == tank.y && isAbility == true)
        {
            if (rangeVtTank > rangeVtHealer)
            {
                tankP2.y--;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeHzTankPlayer2 = tankP2.y;
                SetRange();
                lm.lifeTank -= att;
                turn.isTurn  = true;
                isAbility    = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }

        //sotto healer
        if (Input.GetKeyDown(KeyCode.S) && rangeVtHealer >= -2 && tankP2.y == healerP1.y && isAbility == true)
        {
            if (rangeVtHealer > rangeVtTank)
            {
                tankP2.y--;
                transform.position           = grid.GetWorldPosition(tankP2.x, tankP2.y);
                tankP2.maxRangeVtTankPlayer2 = tankP2.y;
                SetRange();
                lm.lifeHealer -= att;
                turn.isTurn    = true;
                isAbility      = false;
                selectionP2.isActiveTankP2 = false;
                //riabilito input controller per i movimenti(wasd)
                gameObject.GetComponent <InputController>().enabled = true;
            }
        }
    }
    //scelgo direzione dove lanciare l'abilita
    IEnumerator SetDirectionAbility()
    {
        //SetRange();
        //destra TankP2
        if (Input.GetKeyDown(KeyCode.Space) && isAbility == true && tank.isUnitEnemie == false)
        {
            if (tank.hit.transform.gameObject.GetComponent <PositionTester2>())
            {
                DamageTankP2();
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (OnAbility != null)
                {
                    OnAbility();
                }
                if (isAttUp == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x++, tank.y);
                }
                else if (isAttDown == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x--, tank.y);
                }
                else if (isAttRight == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y--);
                }
                else if (isAttLeft == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y++);
                }
                selection.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                selection.transform.DOMoveZ(tank.y, duration).SetAutoKill(false);
                selection.transform.position = grid.GetWorldPosition(tank.x, tank.y);
                selection.x = tank.x;
                selection.y = tank.y;
                tank.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                //tankP2.transform.DOShakePosition(2f, strength, vibrato);
                tank.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank = false;

                GameManager.singleton.sc.isTankUsable = false;
                isAbility = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");

                Counter = 0;
            }
            else if (tank.hit.transform.gameObject.GetComponent <PositionHealer2>())
            {
                DamageHealerP2();
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (OnAbility != null)
                {
                    OnAbility();
                }
                if (isAttUp == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x++, tank.y);
                }
                else if (isAttDown == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x--, tank.y);
                }
                else if (isAttRight == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y--);
                }
                else if (isAttLeft == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y++);
                }
                selection.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                selection.transform.DOMoveZ(tank.y, duration).SetAutoKill(false);
                selection.transform.position = grid.GetWorldPosition(tank.x, tank.y);
                selection.x = tank.x;
                selection.y = tank.y;
                tank.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                //healerP2.transform.DOShakePosition(2f, strength, vibrato);
                tank.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank = false;
                GameManager.singleton.sc.isTankUsable  = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");
                Counter = 0;
            }
            else if (tank.hit.transform.gameObject.GetComponent <PositionUtility2>())
            {
                DamageUtilityP2();
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (OnAbility != null)
                {
                    OnAbility();
                }
                if (isAttUp == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x++, tank.y);
                }
                else if (isAttDown == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x--, tank.y);
                }
                else if (isAttRight == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y--);
                }
                else if (isAttLeft == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y++);
                }
                selection.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                selection.transform.DOMoveZ(tank.y, duration).SetAutoKill(false);
                selection.transform.position = grid.GetWorldPosition(tank.x, tank.y);
                selection.x = tank.x;
                selection.y = tank.y;
                tank.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                isAbility = false;
                //utilityP2.transform.DOShakePosition(2f, strength, vibrato);
                tank.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank = false;
                GameManager.singleton.sc.isTankUsable  = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");
                Counter = 0;
            }
            else if (tank.hit.transform.gameObject.GetComponent <PositionDealer2>())
            {
                DamageDealerP2();
                SoundManager.PlaySound(SoundManager.Sound.tankAbility);
                if (OnAbility != null)
                {
                    OnAbility();
                }
                if (isAttUp == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x++, tank.y);
                }
                else if (isAttDown == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x--, tank.y);
                }
                else if (isAttRight == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y--);
                }
                else if (isAttLeft == true)
                {
                    tank.transform.position = grid.GetWorldPosition(tank.x, tank.y++);
                }
                selection.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                selection.transform.DOMoveZ(tank.y, duration).SetAutoKill(false);
                selection.transform.position = grid.GetWorldPosition(tank.x, tank.y);
                selection.x = tank.x;
                selection.y = tank.y;
                tank.transform.DOMoveX(tank.x, duration).SetAutoKill(false);
                isAbility = false;
                //dealerP2.transform.DOShakePosition(2f, strength, vibrato);
                tank.hit.transform.GetComponent <Player>().HitAnim();
                GameManager.singleton.acm.isActionTank = false;
                GameManager.singleton.sc.isTankUsable  = false;
                yield return(new WaitForSeconds(2f));

                GameManager.singleton.stateMachine.SMController.SetTrigger("GoToSelection");
                Counter = 0;
            }
        }
    }
Esempio n. 21
0
 // Use this for initialization
 void Start()
 {
     transform.position = grid.GetWorldPosition(x, y);
     positionAtt        = FindObjectOfType <AttackBase1>();
 }