Exemplo n.º 1
0
 public override void useCard(Character actor)
 {
     GridNode currentNode = actor.CurrentNode;
     if (actor.Direction == Util.Enums.Direction.Left)
     {
         if (range == 1)
         {
             while (currentNode.Left.Type == Util.Enums.FieldType.Blue)
             {
                 currentNode = currentNode.Left;
             }
             if (!(currentNode.Occupied))
             {
                 currentNode.Left.Type = Util.Enums.FieldType.Blue;
             }
         }
         if (range == 3)
         {
             if (!(currentNode.panelExists(Util.Enums.Direction.Up)))
             {
                 currentNode = currentNode.Down;
             }
             if (!(currentNode.panelExists(Util.Enums.Direction.Down)))
             {
                 currentNode = currentNode.Up;
             }
             GridNode[] stolenPanels = new GridNode[3];
             while (currentNode.Left.Type == Util.Enums.FieldType.Blue && currentNode.Left.Up.Type == Util.Enums.FieldType.Blue && currentNode.Left.Down.Type == Util.Enums.FieldType.Blue)
             {
                 currentNode = currentNode.Left;
             }
             stolenPanels[0] = currentNode.Left;
             stolenPanels[1] = currentNode.Left.Up;
             stolenPanels[2] = currentNode.Left.Down;
             foreach (GridNode node in stolenPanels)
             {
                 if (!(node.Occupied))
                 {
                     node.Type = Util.Enums.FieldType.Blue;
                 }
             }
         }
     }
     if (actor.Direction == Util.Enums.Direction.Right)
     {
         if (range == 1)
         {
             while (currentNode.Right.Type == Util.Enums.FieldType.Red)
             {
                 currentNode = currentNode.Right;
             }
             if (!(currentNode.Occupied))
             {
                 currentNode.Right.Type = Util.Enums.FieldType.Red;
             }
         }
         if (range == 3)
         {
             if (!(currentNode.panelExists(Util.Enums.Direction.Up)))
             {
                 currentNode = currentNode.Down;
             }
             if (!(currentNode.panelExists(Util.Enums.Direction.Down)))
             {
                 currentNode = currentNode.Up;
             }
             GridNode[] stolenPanels = new GridNode[3];
             while (currentNode.Right.Type == Util.Enums.FieldType.Red && currentNode.Right.Up.Type == Util.Enums.FieldType.Red && currentNode.Right.Down.Type == Util.Enums.FieldType.Red)
             {
                 currentNode = currentNode.Right;
             }
             stolenPanels[0] = currentNode.Right;
             stolenPanels[1] = currentNode.Right.Up;
             stolenPanels[2] = currentNode.Right.Down;
             foreach (GridNode node in stolenPanels)
             {
                 if (!(node.Occupied))
                 {
                     node.Type = Util.Enums.FieldType.Red;
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 protected void Move()
 {
     if(!moveCompleted)
         transform.position = Vector3.Lerp(currentNode.transform.position, target.transform.position, pos = pos + Time.deltaTime * speed);
     if(pos > 1)
     {
         moveCompleted = true;
         transform.position = target.transform.position;
         currentNode = target;
         distance--;
         pos = 0;
     }
 }
Exemplo n.º 3
0
        void Update()
        {
            if (Managers.GameManager.State == Enums.GameStates.Battle && !stun)
            {
                if (paused)
                {
                    paused = false;
                    anim.speed = animSpeed;
                }
                if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Up, Type))
                    {
                        directionToMove = Enums.Direction.Up;
                        nextNode = currentNode.Up;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Down, Type))
                    {
                        directionToMove = Enums.Direction.Down;
                        nextNode = currentNode.Down;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Left, Type))
                    {
                        directionToMove = Enums.Direction.Left;
                        nextNode = currentNode.Left;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right, playerNumber))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Right, Type))
                    {
                        directionToMove = Enums.Direction.Right;
                        nextNode = currentNode.Right;
                    }
                }
                else
                    directionToMove = Enums.Direction.None;
                //get next state
                currState = machine.update(hit, animDone, directionToMove, hand.GetCurrentType(), hand.Empty(), playerNumber);

                //state clean up
                if (prevState != currState)
                {
                    doOnce = false;
                    animDone = false;
                    attack = false;
                    basicAttack = false;
                    move = false;
                    hit = false;
                    if (weapon != null)
                        Destroy(weapon);
                    anim.SetInteger("state", (int)currState);
                }
                if (invunTimer > 0)
                {
                    if (renderTimer > renderTime)
                    {
                        render = !render;
                        renderTimer = 0;
                        //GetComponent<Renderer>().enabled = render;
                    }
                    hit = false;
                    renderTimer += Time.deltaTime;
                    invunTimer -= Time.deltaTime;
                }
                else
                {
                    //GetComponent<Renderer>().enabled = true;
                    invun = false;
                }

                //run state
                switch (currState)
                {
                    case Enums.PlayerState.Idle:Idle(); break;
                    case Enums.PlayerState.MoveBegining: MoveBegining(); break;
                    case Enums.PlayerState.MoveEnding: MoveEnding(); break;
                    case Enums.PlayerState.Hit: Hit(); break;
                    case Enums.PlayerState.Dead: Dead(); break;
                    case Enums.PlayerState.BasicAttack: BasicAttack(); break;
                    case Enums.PlayerState.HoriSwingMid: CardAnim(); break;
                    case Enums.PlayerState.VertiSwingHeavy: CardAnim(); break;
                    case Enums.PlayerState.ThrowLight: CardAnim(); break;
                    case Enums.PlayerState.ThrowMid: CardAnim(); break;
                    case Enums.PlayerState.Shoot: CardAnim(); break;
                    case Enums.PlayerState.ChiAttack: CardAnim(); break;
                    case Enums.PlayerState.ChiStationary: CardAnim(); break;
                    case Enums.PlayerState.TauntGokuStretch: Taunt(); break;
                    case Enums.PlayerState.TauntPointPoint: Taunt(); break;
                    case Enums.PlayerState.TauntThumbsDown: Taunt(); break;
                    case Enums.PlayerState.TauntWrasslemania: Taunt(); break;
                    case Enums.PlayerState.TauntYaMoves: Taunt(); break;
                }

                if (move)
                {
                    move = false;
                    currentNode.clearOccupied();
                    currentNode = nextNode;
                    currentNode.Owner = (this);
                    transform.position = currentNode.transform.position;
                }

                if (useCard)
                {
                    if (!hand.Empty())
                    {
                        Enums.CardTypes type = hand.GetCurrentType();
                        if (type == Enums.CardTypes.SwordHori || type == Enums.CardTypes.SwordVert)
                        {
                            weapon = Instantiate(Katana);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0,0,0);

                        }
                        else if (type == Enums.CardTypes.NaginataHori || type == Enums.CardTypes.NaginataVert)
                        {
                            weapon = Instantiate(Naginata);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.HammerHori || type == Enums.CardTypes.HammerVert)
                        {
                            weapon = Instantiate(Hammer);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0,0,0);
                        }
                        else if (type == Enums.CardTypes.Fan)
                        {
                            weapon = Instantiate(Fan);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Kanobo)
                        {
                            weapon = Instantiate(Kanobo);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Tanto)
                        {
                            weapon = Instantiate(Tanto);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Wakizashi)
                        {
                            weapon = Instantiate(Wakizashi);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.Tonfa)
                        {
                            weapon = Instantiate(Tonfa);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        else if (type == Enums.CardTypes.BoStaff)
                        {
                            weapon = Instantiate(BoStaff);
                            weapon.transform.position = weaponPoint.position;
                            weapon.transform.localScale = weaponPoint.localScale;
                            weapon.transform.parent = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        useCard = false;
                        hand.UseCurrent(this);
                        CardUIEvent();
                    }
                }

                if (basicAttack)
                {
                    basicAttack = false;
                    Weapons.Hitbox b = Instantiate(bullet);
                    AddElement.AddElementByEnum(b.gameObject,(Enums.Element)Random.Range(0,5),true);
                    b.Owner = this.gameObject;
                    b.transform.position = Direction == Enums.Direction.Left ? currentNode.Left.transform.position : currentNode.Right.transform.position;
                    b.CurrentNode = Direction == Enums.Direction.Left ? currentNode.Left : currentNode.Right;
                    b.Direction = Direction;
                }

                if (damage > 0 && takeDamage)
                {
                    takeDamage = false;
                    TakeDamage(damage, damageElement);
                    damage = 0;
                    damageElement = Enums.Element.None;
                }
                prevState = currState;
            }
            else
            {
                if (!paused)
                {
                    animSpeed = anim.speed;
                    anim.speed = 0;
                    paused = true;
                }
                if (stun)
                {
                    if ((stunTimer += Time.deltaTime) > stunTime)
                    {
                        stunTimer = 0f;
                        stun = false;
                    }
                }
            }
        }
Exemplo n.º 4
0
 public virtual void Update()
 {
     if (Managers.GameManager.State == Enums.GameStates.Battle)
     {
         if (moveCompleted)
         {
             switch (direction)
             {
                 case Enums.Direction.Up:
                     if (isFlying)
                     {
                         if (currentNode.panelExists(Enums.Direction.Up))
                             target = currentNode.Up;
                         else
                             dead = true;
                     }
                     else
                     {
                         if (currentNode.panelNotDestroyed(Enums.Direction.Up))
                             target = currentNode.Up;
                         else
                             dead = true;
                     }
                     moveCompleted = false;
                     break;
                 case Enums.Direction.Down:
                     if (isFlying)
                     {
                         if (currentNode.panelExists(Enums.Direction.Down))
                             target = currentNode.Down;
                         else
                             dead = true;
                     }
                     else
                     {
                         if (currentNode.panelNotDestroyed(Enums.Direction.Down))
                             target = currentNode.Down;
                         else
                             dead = true;
                     }
                     moveCompleted = false;
                     break;
                 case Enums.Direction.Left:
                     if (isFlying)
                     {
                         if (currentNode.panelExists(Enums.Direction.Left))
                             target = currentNode.Left;
                         else
                             dead = true;
                     }
                     else
                     {
                         if (currentNode.panelNotDestroyed(Enums.Direction.Left))
                             target = currentNode.Left;
                         else
                             dead = true;
                     }
                     moveCompleted = false;
                     break;
                 case Enums.Direction.Right:
                     if (isFlying)
                     {
                         if (currentNode.panelExists(Enums.Direction.Right))
                             target = currentNode.Right;
                         else
                             dead = true;
                     }
                     else
                     {
                         if (currentNode.panelNotDestroyed(Enums.Direction.Right))
                             target = currentNode.Right;
                         else
                             dead = true;
                     }
                     moveCompleted = false;
                     break;
                 default: deathTime -= Time.deltaTime; break;
             }
         }
         if (deathTime < 0 || dead || distance == 0)
             Destroy(this.gameObject);
         Move();
     }
 }
Exemplo n.º 5
0
        void Update()
        {
            if (Managers.GameManager.State == Enums.GameStates.Battle)
            {
                if (CustomInput.BoolFreshPress(CustomInput.UserInput.Up))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Up, Type))
                    {
                        direction = Enums.Direction.Up;
                        nextNode = currentNode.Up;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Down))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Down, Type))
                    {
                        direction = Enums.Direction.Down;
                        nextNode = currentNode.Down;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Left))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Left, Type))
                    {
                        direction = Enums.Direction.Left;
                        nextNode = currentNode.Left;
                    }
                }
                else if (CustomInput.BoolFreshPress(CustomInput.UserInput.Right))
                {
                    if (currentNode.panelAllowed(Enums.Direction.Right, Type))
                    {
                        direction = Enums.Direction.Right;
                        nextNode = currentNode.Right;
                    }
                }
                else
                    direction = Enums.Direction.None;
                //get next state
                currState = machine.update(hit, animDone, direction, hand.GetCurrentType(), hand.Empty());

                //state clean up
                if (prevState != currState)
                {
                    doOnce = false;
                    animDone = false;
                    hit = false;
                    anim.SetInteger("state", (int)currState);
                }
                if (invunTimer > 0)
                {
                    if (renderTimer > renderTime)
                    {
                        render = !render;
                        renderTimer = 0;
                        //GetComponent<Renderer>().enabled = render;
                    }
                    hit = false;
                    renderTimer += Time.deltaTime;
                    invunTimer -= Time.deltaTime;
                }
                else
                {
                    //GetComponent<Renderer>().enabled = true;
                    invun = false;
                }

                //run state
                doState[(int)currState]();

                if (move)
                {
                    move = false;
                    currentNode.clearOccupied();
                    currentNode = nextNode;
                    currentNode.Owner = (this);
                    transform.position = currentNode.transform.position;
                }

                if (useCard)
                {
                    if (!hand.Empty())
                    {
                        useCard = false;
                        hand.UseCurrent(this);
                        CardUIEvent();
                    }
                }

                if (basicAttack)
                {
                    basicAttack = false;
                    Weapons.Projectiles.Bullet b = Instantiate(bullet).GetComponent<Weapons.Projectiles.Bullet>();
                    b.transform.position = barrel.position;
                    b.Direction = Direction;
                }

                if (damage > 0 && takeDamage)
                {
                    takeDamage = false;
                    TakeDamage(damage);
                    damage = 0;
                }
                prevState = currState;
            }
        }