示例#1
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;
            }
        }
        void Update()
        {
            if (GameManager.State == GameState.Lose)
            {
                Destroy(this.gameObject);
                return;
            }
            if (!GameManager.SuspendedState)
            {
                if (Input.GetKey(KeyCode.UpArrow))
                {
                    colorData.AddColor(Color.white, 500f);
                }

                //going Achromic
                if (CustomInput.SuperFreshPress && colorData.isfull())
                {
                    achromic = true;
                }

                if (temp++ > 3)
                {
                    animDone = true;
                }

                TouchingSomething();
                if (_ghost)
                {
                    inAir = true;
                }
                //get next state
                currState = machine.update(inAir, blockSucessful, hit, animDone);
                if (invunTimer > 0)
                {
                    if (renderTimer > renderTime)
                    {
                        render      = !render;
                        renderTimer = 0;
                        foreach (PlayerArmor pa in _armor)
                        {
                            pa.GetComponent <Renderer>().enabled = render;
                        }
                    }
                    hit          = false;
                    renderTimer += Time.deltaTime;
                    invunTimer  -= Time.deltaTime;
                }
                else
                {
                    foreach (PlayerArmor pa in _armor)
                    {
                        pa.GetComponent <Renderer>().enabled = true;
                    }
                    invun = false;
                }

                //run state
                doState[(int)currState]();
                //state clean up
                if (blockSucessful)
                {
                    parryTimer += Time.deltaTime;
                    if (parryTimer > parryTime)
                    {
                        blockSucessful = false;
                        parryTimer     = 0;
                    }
                }
                if (prevState != currState)
                {
                    doOnce   = false;
                    animDone = false;
                    temp     = 0;
                    attack.Hide();
                    block.Hide();
                    _jump          = false;
                    blocking       = false;
                    blockSucessful = false;
                    parryTimer     = 0;
                    hit            = false;
                    anim.SetInteger("state", (int)currState);
                }
                prevState = currState;

                Ghosting();
            }
        }
示例#3
0
        void Update()
        {
            if (Managers.GameManager.State == Enums.GameStates.Battle && !stun)
            {
                if (paused)
                {
                    paused     = false;
                    anim.speed = animSpeed;
                }
                #region detectMove
                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;
                }
                #endregion
                //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;
                        foreach (SkinnedMeshRenderer b in body)
                        {
                            b.enabled = render;
                        }
                    }
                    hit          = false;
                    renderTimer += Time.deltaTime;
                    invunTimer  -= Time.deltaTime;
                }
                else if (!render || invun)
                {
                    render = true;
                    foreach (SkinnedMeshRenderer b in body)
                    {
                        b.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;
                }
                #region useCard
                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);
                        }
                        if (type == Enums.CardTypes.WideSword)
                        {
                            weapon = Instantiate(WideSword);
                            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 / .8f;
                            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 / .8f;
                            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 / .5f;
                            weapon.transform.parent           = weaponPoint;
                            weapon.transform.localEulerAngles = new Vector3(0, 0, 0);
                        }
                        int sfxNumber = 0;
                        switch (type)
                        {
                        case Enums.CardTypes.SwordVert:
                        case Enums.CardTypes.SwordHori:
                        case Enums.CardTypes.WideSword:
                        case Enums.CardTypes.NaginataVert:
                        case Enums.CardTypes.NaginataHori:
                        case Enums.CardTypes.HammerVert:
                        case Enums.CardTypes.HammerHori:
                        case Enums.CardTypes.Fan:
                        case Enums.CardTypes.Kanobo:
                        case Enums.CardTypes.Tanto:
                        case Enums.CardTypes.Wakizashi:
                        case Enums.CardTypes.Tonfa:
                        case Enums.CardTypes.BoStaff: sfxNumber = 0; break;

                        case Enums.CardTypes.ThrowLight:
                        case Enums.CardTypes.ThrowMid:
                        case Enums.CardTypes.Shoot: sfxNumber = 2; break;

                        case Enums.CardTypes.ChiAttack:
                        case Enums.CardTypes.ChiStationary: sfxNumber = 3; break;

                        default: break;
                        }
                        sfx.PlaySong(sfxNumber);
                        useCard = false;
                        hand.UseCurrent(this, deck);
                        CardUIEvent();
                    }
                }
                #endregion

                if (basicAttack)
                {
                    basicAttack = false;
                    Weapons.Hitbox b = Instantiate(bullet);
                    AddElement.AddElementByEnum(b.gameObject, element, 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 (playerNumber == 2)
                    {
                        Transform model = b.transform.GetChild(0);
                        model.localScale = new Vector3(model.localScale.x, -model.localScale.y, model.localScale.z);
                    }
                    sfx.PlaySong(2);
                }

                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;
                    }
                }
            }
        }
示例#4
0
        void Update()
        {
            if (Util.GameState.state == Util.GameState.State.Playing && !disable)
            {
                if (paused)
                {
                    paused           = false;
                    anim.speed       = animSpeed;
                    rgbdy.useGravity = true;
                    rgbdy.velocity   = vel;
                }
                if (Input.GetKeyUp(KeyCode.U))
                {
                    die();
                }

                #region StatusEffects
                if (sluggish)
                {
                    anim.speed = 0.6f;
                }
                else
                {
                    anim.speed = 1;
                }
                #endregion
                anim.SetFloat("speed", magnitude);
                if (health <= 0 || this.transform.position.y < -20)
                {
                    //Create a ragdoll until we respawn
                    if (respawnTimer > 0)
                    {
                        if (!ragdollIsActive)
                        {
                            die();
                            //this.GetComponent<Rigidbody>().useGravity = false;
                        }
                        //this.gameObject.transform.position = new Vector3(tempRag.HipN.position.x+1,tempRag.HipN.position.y, tempRag.HipN.position.z + 1);
                        respawnTimer -= Time.deltaTime;
                    }
                    else
                    {
                        Respawn();
                        FindObjectOfType <GameState>().playerDeaths++;
                        FindObjectOfType <GameState>().lives--;
                        //this.GetComponent<Rigidbody>().useGravity = true;
                    }
                }
                move = false;

                if (CustomInput.Bool(CustomInput.UserInput.Up) || CustomInput.Bool(CustomInput.UserInput.Down) || CustomInput.Bool(CustomInput.UserInput.Left) || CustomInput.Bool(CustomInput.UserInput.Right))
                {
                    move = true;
                }
                TouchingSomething();
                //get next state
                currState = machine.update(inAir, move, hit, animDone);
                if (invunTimer > 0)
                {
                    hit         = false;
                    invunTimer -= Time.deltaTime;
                    invun       = true;
                }
                else
                {
                    invun = false;
                }
                if (dead)
                {
                    dead = false;
                }
                //run state
                doState[(int)currState]();
                if (health <= 0)
                {
                    die();
                }
                if (doAttack)
                {
                    doAttack       = false;
                    attackInstance = Instantiate(attack);
                    attackInstance.transform.position = attackPos.position;
                }
                //state clean up
                if (prevState != currState)
                {
                    doOnce   = false;
                    animDone = false;
                    jump     = false;
                    hit      = false;
                    anim.SetInteger("state", (int)currState);
                    if (attackInstance != null)
                    {
                        Destroy(attackInstance.gameObject);
                    }
                }
                prevState = currState;
            }
            else
            {
                if (!paused)
                {
                    animSpeed        = anim.speed;
                    anim.speed       = 0;
                    rgbdy.useGravity = false;
                    vel            = rgbdy.velocity;
                    rgbdy.velocity = new Vector3();
                    paused         = true;
                }
            }
        }