Exemplo n.º 1
0
 private void FixedUpdate()
 {
     if (m_gamecontroller.IsGameStart)
     {
         if (!isStun)
         {
             Movement(JoystickInputController.GetMovement(controllerSelecte));
         }
     }
 }
Exemplo n.º 2
0
 private void Start()
 {
     _joyInputController  = JoystickInputController.Instance;
     _characterController = GetComponent <CharacterController>();
 }
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     _joystickInstance = JoystickInputController.Instance;
     _keyboardInstance = KeyboardInputController.Instance;
 }
Exemplo n.º 4
0
    private void Update()
    {
        if (m_gamecontroller.IsGameStart)
        {
            if (speedUpCount < Time.time)
            {
                currentSpeed = Maxspeed;
            }
            if (!isStun)
            {
                if (JoystickInputController.GetUse(controllerSelecte))
                {
                    if (inventory != null)
                    {
                        switch (inventory.itemType)
                        {
                        case ItemType.Plank:
                            inventory.Use(agentParent.transform.position + agentParent.transform.forward, agentParent.gameObject);
                            StartCoroutine(PlankVisible());
                            m_itemcontroller.currentPlank--;
                            audioSource.PlayOneShot(hitClip);
                            Destroy(inventory.gameObject);
                            break;

                        case ItemType.Bomb:
                            inventory.Use(agentParent.transform.forward);
                            break;

                        case ItemType.Boots:
                            inventory.Use(ref currentSpeed, out speedUpCount);
                            Destroy(inventory.gameObject);
                            break;

                        case ItemType.Hay:
                            inventory.Use(m_chickenController);
                            Destroy(inventory.gameObject);
                            break;
                        }

                        anim.SetTrigger("Hit");
                        inventory = null;
                    }
                    else
                    {
                        if (collectObject != null)
                        {
                            anim.SetTrigger("Get");
                            collectObject.Collect(agentParent.gameObject);
                            inventory = collectObject;
                        }
                    }
                }
                if (pushObject != null)
                {
                    if (JoystickInputController.GetPush(controllerSelecte))
                    {
                        pushObject.transform.parent = this.transform;
                        currentPush = pushObject;
                        pushObject.transform.Find("Chicken").transform.localPosition = new Vector3(0, 0.5f, 0);
                        Chicken chicken = pushObject.GetComponentInChildren <Chicken>();
                        chicken.isOnpush = true;
                        isPush           = true;
                        anim.SetBool("isSheepHed", true);
                        anim.SetBool("isRunning", false);
                        chicken.whoPush = this.gameObject;
                        speed           = currentSpeed * 0.7f;
                    }
                    else if (currentPush != null)
                    {
                        try
                        {
                            currentPush.transform.parent = null;
                            Chicken chicken = currentPush.GetComponentInChildren <Chicken>();
                            chicken.isOnpush = false;
                            isPush           = false;
                            anim.SetBool("isSheepHed", false);
                            chicken.whoPush = null;
                            speed           = currentSpeed;
                        }
                        catch (System.NullReferenceException)
                        {
                            isPush = false;
                            anim.SetBool("isSheepHed", false);
                            speed = currentSpeed;
                        }
                    }
                }
                else if (currentPush != null)
                {
                    try
                    {
                        currentPush.transform.parent = null;
                        Chicken chicken = currentPush.GetComponentInChildren <Chicken>();
                        chicken.isOnpush = false;
                        isPush           = false;
                        anim.SetBool("isSheepHed", false);
                        chicken.whoPush = null;
                        speed           = currentSpeed;
                    }
                    catch (System.NullReferenceException)
                    {
                        isPush = false;
                        anim.SetBool("isSheepHed", false);
                        speed = currentSpeed;
                    }
                }
                else
                {
                    speed = currentSpeed;
                }
            }
            else
            {
                try
                {
                    currentPush.transform.parent = null;
                    Chicken chicken = currentPush.GetComponentInChildren <Chicken>();
                    chicken.isOnpush = false;
                    isPush           = false;
                    anim.SetBool("isSheepHed", false);
                    chicken.whoPush = null;
                    speed           = currentSpeed;
                }
                catch (System.NullReferenceException)
                {
                    isPush = false;
                    anim.SetBool("isSheepHed", false);
                    speed = currentSpeed;
                }
                if (stunCount < Time.time)
                {
                    isStun = false;
                    anim.SetBool("isStun", false);
                }
            }
        }
    }