private void Start()
 {
     playerIdle      = GetComponent <PlayerIdle>();
     playerWalking   = GetComponent <PlayerWalking>();
     playerCrouching = GetComponent <PlayerCrouching>();
     playerJumping   = GetComponent <PlayerJumping>();
 }
 /// <summary>
 /// Awake
 /// </summary>
 void Awake()
 {
     a = GetComponent<Animator>();
     j = GetComponent<PlayerJumping>();
     t = transform;
     pm = GetComponent<PlayerMotor>();
 }
    private void CreateNetwork()
    {
        dead     = new PlayerDead(this);
        walking  = new PlayerWalking(this);
        jumping  = new PlayerJumping(jumpBufferTime, this);
        rising   = new PlayerRising(this);
        falling  = new PlayerFalling(this);
        flipping = new PlayerFlipping(flipTime, flipOffset, this);

        walking.AddTransition(dead);
        walking.AddTransition(jumping);
        walking.AddTransition(rising);
        walking.AddTransition(falling);
        walking.AddTransition(flipping);

        jumping.AddTransition(dead);
        jumping.AddTransition(walking);
        jumping.AddTransition(rising);
        jumping.AddTransition(falling);
        jumping.AddTransition(flipping);

        rising.AddTransition(dead);
        rising.AddTransition(walking);
        rising.AddTransition(falling);
        rising.AddTransition(flipping);

        falling.AddTransition(dead);
        falling.AddTransition(walking);
        falling.AddTransition(rising);

        flipping.AddTransition(walking);
        flipping.AddTransition(falling);

        activeState = walking;
    }
Exemple #4
0
    void Start()
    {
        transform.position = SpawnPos.transform.position;

        rb   = GetComponent <Rigidbody>();
        body = GetComponent <CapsuleCollider>();

        movement           = new PlayerMovement();
        jump               = new PlayerJumping();
        movement.direction = transform.TransformDirection(Vector3.forward);
        Spawn();
    }
Exemple #5
0
 private void Start()
 {
     if (!GetComponent <Player>().networkObject.IsOwner)
     {
         this.enabled = false;
         return;
     }
     pl               = GetComponent <PlayerLooking>();
     pj               = GetComponent <PlayerJumping>();
     pm               = GetComponent <PlayerMovement>();
     pi               = GetComponent <PlayerInteract>();
     locked           = true;
     Cursor.lockState = CursorLockMode.Locked;
 }
Exemple #6
0
	/// <summary>
	/// Initialize player movement.
	/// </summary>
	void Awake() {
        //Time.timeScale = 0.33f;
        t = transform;
        a = GetComponent<Animator>();
        cl = GetComponent<PlayerClimbing>();
        cam = GetComponent<PlayerCamera>();
        atk = GetComponent<PlayerAttack>();
        j = GetComponent<PlayerJumping>();
        move_direction = transform.forward;
	}
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag.Equals("Player"))
        {
            if (collision.contacts.Length > 0)
            {
                ContactPoint contact = collision.contacts[0];
                if (Vector3.Dot(contact.normal, Vector3.down) > 0.5f)
                {
                    //Grabs the player jumping script from the player the enemy made collision with
                    PlayerJumping jump = collision.gameObject.GetComponent <PlayerJumping>();
                    //Makes the player jump up
                    jump.Jump(5f);
                    soundPlayer.PlaySound(Sounds.KICKING);
                    if (!stompedHead)
                    {
                        stompedHead = true;
                        gameManager.IncreaseScore(score);

                        //Checks if the enemy has to been deleted from the scene
                        if (enemy.deleted)
                        {
                            gameObject.SetActive(false);                //Destroy(gameObject);
                        }
                        //Pauses the movement of the enemy
                        else
                        {
                            pauseMovement = true;
                        }
                    }
                    else
                    {
                        kickedEnemy = true;
                    }
                }
                //Checks if the player hits the enemy while its not moving anymore
                else if (stompedHead && pauseMovement)
                {
                    //Grabs the new direction of the enemy
                    direction   = (int)Input.GetAxisRaw("Horizontal");
                    kickedEnemy = true;
                    soundPlayer.PlaySound(Sounds.KICKING);
                }
                else
                {
                    gameManager.HandleDeath();
                }
            }
        }
        else if (collision.gameObject.tag.Equals("Floor") || collision.gameObject.tag.Equals("Interactable"))
        {
            //Switch direction
            direction = direction == 1 ? -1 : 1;
            //Checks if the enemy hit a interactable and is in shell form (aka been stomped and moving)
            if (collision.gameObject.tag.Equals("Interactable") && stompedHead)
            {
                BlockHandler blockHandler = collision.gameObject.GetComponent <BlockHandler>();
                blockHandler.HandleCollision();
            }
        }
    }
 // Start is called before the first frame update
 void Awake()
 {
     playerInput   = new PlayerInput();
     playerJumping = GetComponent <PlayerJumping>();
     animator      = GetComponent <Animator>();
 }