Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        //Refs
        RightHand = transform.FindChild("Root/Hips/Spine/Chest/RightShoulder/RightUpperArm/RightLowerArm/RightHand");
        Charac = transform.GetComponent<Rigidbody>();
        GameControle = GameObject.Find("GameControle");
        tPlayerAnimator = transform.GetComponent<Animator>();
        //transform.FindChild( "Viseur" ).FindChild( "Direction" ).FindChild( "Arrow" ).gameObject.SetActive( false );
        //Ball = null;

        //initializations
        tInitialPos = transform.position;
        Mat = transform.FindChild("Rys").GetComponent<Renderer>().material;
        Charac.drag = CharacDrag;
        eStateBall = EStatePlayerBall.Standby;
        eStateMove = EStatePlayerMove.Standby;
        m_eInputType = EPlayerInputType.B;
        tPlayerAnimator.SetInteger("Dir", 0);

        GrabTimer = MaxGrabbingTime;
        DodgeTimer = MaxDodgeTime;

        if (m_eInputType == EPlayerInputType.B && Ball == null)//tmp
            Ball = GameObject.FindGameObjectWithTag("Ball");
    }
Exemplo n.º 2
0
    void Move(EPlayerInputType eInputType, bool bMode)
    {
        if (bGoToInit == false)
        {
            Vector3 tDir = Vector3.zero;
            //translate
            float AxeX = Input.GetAxis("Horizontal_P" + m_iPlayerId);
            float AxeY = Input.GetAxis("Vertical_P" + m_iPlayerId);
            tDir = new Vector3(AxeX, 0, AxeY);

            //anim settup
            UpdateDirection();

            if (bMode == MOVE)
            {
                AnimUpdate(tDir);
                Charac.AddForce(tDir * Speed * Time.deltaTime, ForceMode.Impulse);
            }
            else
            {
                AnimUpdate( tDir );

                Charac.velocity = new Vector3(0, 0, 0);
            }

            //rotate
            switch (eInputType)
            {
                case EPlayerInputType.A:
                    {
                        RightAxisRotation();
                        break;
                    }
                case EPlayerInputType.B:
                    {
                        if (bMode == MOVE)
                        {
                            if (tPlayerAnimator.GetInteger("Dir") != 0)
                                Charac.transform.LookAt(new Vector3(Ball.transform.position.x, 0, Ball.transform.position.z));
                        }
                        else
                            RightAxisRotation();
                        break;
                    }
                case EPlayerInputType.C:
                    {
                        if (bMode == MOVE)
                            Charac.transform.LookAt(new Vector3(Ball.transform.position.x, 0, Ball.transform.position.z));
                        else
                            RightAxisRotation();
                        break;
                    }
            }
        }
    }