Exemplo n.º 1
0
 void AxeAttack()
 {
     canAttack = false;
     animator.SetTrigger("Attack");
     velocity.x = 0;
     state      = WoodcutterState.AxeAttack;
 }
Exemplo n.º 2
0
 void LogKick()
 {
     canLogKick = false;
     animator.SetTrigger("LogKick");
     velocity.x = 0;
     state      = WoodcutterState.LogKick;
 }
Exemplo n.º 3
0
 void SawThrow(int sawNum = 1)
 {
     canSawThrow = false;
     animator.SetTrigger("SawThrow");
     velocity.x = 0;
     sawNumber  = sawNum;
     state      = WoodcutterState.SawToss;
 }
Exemplo n.º 4
0
 public override void Death()
 {
     StopAllCoroutines();
     alive = false;
     base.Death();
     state = WoodcutterState.Dead;
     enterDoor.SendMessage("Unlock");
     exitDoor.SendMessage("Unlock");
     GameControl.ResetOnRest -= Reset;
     GameControl.control.woodcutterDefeated = true;
     Destroy(this.gameObject);
 }
Exemplo n.º 5
0
 public void EndJump()
 {
     ResetAnimation();
     jumpResetTimer = jumpResetTime;
     if (!inPhaseTwo)
     {
         if (canLogKick || canSawThrow)
         {
             if (canLogKick && canSawThrow)
             {
                 int rndNum = UnityEngine.Random.Range(-1, 1);
                 if (rndNum > 0)
                 {
                     LogKick();
                 }
                 else
                 {
                     SawThrow();
                 }
             }
             else if (!canSawThrow)
             {
                 LogKick();
             }
             else if (!canLogKick)
             {
                 SawThrow();
             }
         }
         else
         {
             state = WoodcutterState.Walk;
         }
     }
     else
     {
         canAct = false;
         actionCooldownTimer = actionCooldownTime;
         int rndNum = UnityEngine.Random.Range(-1, 1);
         if (rndNum > -.25f)
         {
             LogKick();
         }
         else
         {
             SawThrow();
         }
     }
 }
Exemplo n.º 6
0
 void Activate()
 {
     if (state == WoodcutterState.Inactive)
     {
         if (playInro)
         {
             animator.SetTrigger("PlayIntro");
             state    = WoodcutterState.Into;
             playInro = false;
         }
         else
         {
             state = WoodcutterState.Walk;
         }
     }
 }
Exemplo n.º 7
0
 void Jump(int direction)
 {
     canJump            = false;
     jumpStartAnimation = true;
     jumpDirection      = direction;
     jumpTimer          = jumpDuration;
     state = WoodcutterState.Jump;
     animator.ResetTrigger("EndJump");
     if (controller.collisions.faceDirection == direction)
     {
         animator.SetTrigger("JumpForward");
     }
     else
     {
         animator.SetTrigger("JumpBack");
     }
 }
Exemplo n.º 8
0
 void Reset()
 {
     Debug.Log("woodcutter reset");
     transform.position = startingPos;
     hitsLeft           = maxHits;
     energyLeft         = maxEnergy;
     velocity.x         = 0;
     OnScreen           = false;
     jumpStartAnimation = false;
     inPhaseTwo         = false;
     StartingFaceDirection();
     animator.SetTrigger("EndJump");
     ResetAnimation();
     state = WoodcutterState.Inactive;
     animator.Play("Idle");
     sameAttackCounter = 0;
     SetAnimParameters();
     Debug.Log(state);
 }
Exemplo n.º 9
0
 public void DeactivaeAttack()
 {
     if (inPhaseTwo)
     {
         if (secondProjectile)
         {
             Debug.Log("set second projectile to false");
             hitboxAxeAttack.SetActive(false);
             if (state == WoodcutterState.SawToss)
             {
                 state           = WoodcutterState.Walk;
                 thirdProjectile = true;
                 SawThrow(2);
             }
             else if (state == WoodcutterState.LogKick)
             {
                 state = WoodcutterState.Walk;
                 LogKick();
             }
             else
             {
                 state = WoodcutterState.Walk;
             }
             secondProjectile = false;
         }
         else if (thirdProjectile)
         {
             state = WoodcutterState.Walk;
             SawThrow(3);
             thirdProjectile = false;
         }
         else
         {
             hitboxAxeAttack.SetActive(false);
             state = WoodcutterState.Walk;
         }
     }
     else
     {
         hitboxAxeAttack.SetActive(false);
         state = WoodcutterState.Walk;
     }
 }
Exemplo n.º 10
0
    // Update is called once per frame
    public override void Update()
    {
        if (hitsLeft <= phaseTwoHits && !inPhaseTwo)
        {
            SetPhaseTwo();
        }
        if (isKnockbacked && (state != WoodcutterState.Knockback || state != WoodcutterState.Jump))
        {
            state = WoodcutterState.Knockback;
        }
        AttackCooldown();
        switch (state)
        {
        case WoodcutterState.Inactive:
        {
            controller.AddGravity(ref velocity);

            break;
        }

        case WoodcutterState.Into:
        {
            controller.AddGravity(ref velocity);
            // play into animation and cutsene
            GameControl.control.woodcutterEncountered = true;
            break;
        }

        case WoodcutterState.Walk:
        {
            if (target != null)
            {
                //controller.collisions.faceDirection = (target.transform.position.x >= transform.position.x) ? 1 : -1;

                if (target.transform.position.x >= transform.position.x)
                {
                    if (controller.collisions.faceDirection == -1)
                    {
                        state     = WoodcutterState.Turn;
                        turnTimer = turnTime;
                    }
                }
                else
                {
                    if (controller.collisions.faceDirection == 1)
                    {
                        state     = WoodcutterState.Turn;
                        turnTimer = turnTime;
                    }
                }
                controller.AddGravity(ref velocity);
                velocity.x = controller.collisions.faceDirection * walkSpeed * Time.deltaTime;
                // choose what action is preformed


                if (Mathf.Abs(transform.position.x - target.transform.position.x) <= 1.8f)
                {
                    velocity.x = 0;
                    AttackCooldown();
                }

                if (canAct)
                {
                    Debug.Log("Takes action");
                    decideAction(Mathf.Abs(transform.position.x - target.transform.position.x));
                }

                SetAnimParameters();
                controller.Move(velocity);
            }
            else
            {
                Reset();
            }

            break;
        }

        case WoodcutterState.Turn:
        {
            if (turnTimer > 0.1)
            {
                turnTimer -= Time.deltaTime;
                controller.AddGravity(ref velocity);
                velocity.x = controller.collisions.faceDirection * walkSpeed * Time.deltaTime;
                controller.Move(velocity);
            }
            else if (turnTimer < 0.1 && turnTimer > 0)
            {
                turnTimer -= Time.deltaTime;
            }
            else if (turnTimer <= 0)
            {
                if (controller.collisions.faceDirection == -1)
                {
                    FaceRight();
                }
                else if (controller.collisions.faceDirection == 1)
                {
                    FaceLeft();
                }
            }
            break;
        }

        case WoodcutterState.Knockback:
        {
            if (knockbackTimer <= 0 && controller.collisions.below)
            {
                // stop knockback
                isKnockbacked = false;
                velocity.y    = 0;
                state         = WoodcutterState.Walk;
            }
            else if (knockbackTimer <= 0 && !controller.collisions.below)
            {
                controller.AddGravity(ref velocity);
                velocity.x = knockbackAmount * knockbackDirection.x * Time.deltaTime;
                controller.Move(velocity);
            }
            else
            {
                knockbackTimer -= Time.deltaTime;

                velocity.y = ((knockbackAmount * knockbackDirection.y) / 2) * Time.deltaTime;
                velocity.x = knockbackAmount * knockbackDirection.x * Time.deltaTime;
                controller.Move(velocity);
            }
            break;
        }

        case WoodcutterState.AxeAttack:
        {
            attackResetTimer = attackResetTime;
            velocity.x       = 0;
            SetAnimParameters();
            break;
        }

        case WoodcutterState.LogKick:
        {
            logKickResetTimer = logKickResetTime;
            velocity.x        = 0;
            SetAnimParameters();
            break;
        }

        case WoodcutterState.SawToss:
        {
            sawThrowResetTimer = logKickResetTime;
            velocity.x         = 0;
            SetAnimParameters();
            break;
        }

        case WoodcutterState.Jump:
        {
            if (jumpStartAnimation)
            {
            }
            else
            {
                if (jumpTimer > 0)
                {
                    jumpTimer -= Time.deltaTime;
                    velocity.x = jumpDirection * jumpXSpeed * Time.deltaTime;
                    velocity.y = jumpVelocity * Time.deltaTime;
                    controller.Move(velocity);
                }
                if (jumpTimer <= 0)
                {
                    controller.AddGravity(ref velocity);
                    if (!controller.collisions.below)
                    {
                        velocity.x = jumpDirection * jumpXSpeed * Time.deltaTime;
                    }
                    else if (controller.collisions.below)
                    {
                        velocity.x = 0;
                        JumpLand();
                    }
                    controller.Move(velocity);
                }
            }
            break;
        }

        case WoodcutterState.Dead:
        {
            velocity.x = 0;
            break;
        }
        }
    }
Exemplo n.º 11
0
 public override void FaceRight()
 {
     base.FaceRight();
     controller.collisions.faceDirection *= -1;
     state = WoodcutterState.Walk;
 }
Exemplo n.º 12
0
 public void FinishIntro()
 {
     state = WoodcutterState.Walk;
 }
Exemplo n.º 13
0
    IEnumerator ActiveDelay()
    {
        yield return(new WaitForSecondsRealtime(.2f));

        state = WoodcutterState.Walk;
    }