コード例 #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");
    }
コード例 #2
0
    void MoveUpdate()
    {
        switch (eStateMove)
        {
            case EStatePlayerMove.Run:
                {
                    if (DodgeTimer < MaxDodgeTime)
                    {
                        DodgeTimer += Time.deltaTime;
                    }

                    if (Input.GetButtonDown("Dodge_P" + m_iPlayerId))
                    {
                        eStateMove = EStatePlayerMove.Dodging;
                        eStateBall = EStatePlayerBall.Grab;
                        SmashTimer = MaxDodgeTime;
                    }

                    if (RecupTime <= 0.0f)
                    {
                        Move(m_eInputType, MOVE);
                    }

                    break;
                }
            case EStatePlayerMove.RunWithBall:
                {
                    Move(m_eInputType, SMASH);
                    break;
                }
            case EStatePlayerMove.Dodging:
                {
                    Dodge();
                    break;
                }
            case EStatePlayerMove.Standby:
                {
                    break;
                }
        }
    }
コード例 #3
0
    void BallBehaviorUpdate()
    {
        switch (eStateBall)
        {
            case EStatePlayerBall.Idle:
                {
                    if (Input.GetButtonDown("Shoot_P" + m_iPlayerId))
                    {
                        eStateBall = EStatePlayerBall.Grab;
                        SmashTimer = MaxGrabbingTime;
                        //Mat.color = Color.red;
                    }

                    if (Input.GetButton("Shield_P" + m_iPlayerId))
                    {
                        this.transform.FindChild("Shield").GetComponent<ShieldScript>().ShieldOn();
                    }
                    else
                    {
                        this.transform.FindChild("Shield").GetComponent<ShieldScript>().ShieldOff();
                    }
                    break;
                }
            case EStatePlayerBall.Grab:
                {
                    SmashTimer -= Time.deltaTime;

                    if (SmashTimer <= 0.0f)
                    {
                        //Mat.color = new Color(1, 1, 1);
                        eStateBall = EStatePlayerBall.Idle;
                        eStateMove = EStatePlayerMove.Run;
                    }
                    break;
                }
            case EStatePlayerBall.Smash:
                {
                    //ChangeColor();
                    GrabTimer -= Time.deltaTime;

                    UpdateCurvePattern();
                    eStateMove = EStatePlayerMove.RunWithBall;
                    IgnoreBallsCollisions(true);
                    Ball.transform.position = RightHand.position;

                    if (GrabTimer <= 0.0f)
                    {
                        eStateBall = EStatePlayerBall.Idle;
                        eStateMove = EStatePlayerMove.Run;

                        if (Ball != null)
                        {
                            Ball.GetComponent<BallControl>().Launch(TestBallCurve());
                            DesactivatePattern();
                            RecupTime = MaxRecupTime;

                            //if (m_eInputType != EPlayerInputType.B)//tmp
                            //    Ball = null;
                        }
                        GrabTimer = MaxGrabbingTime;
                    }
                    break;
                }
            case EStatePlayerBall.Dead:
                {
                    eStateMove = EStatePlayerMove.Standby;

                    if (iScore < MaxScore)
                    {
                        GameControle.GetComponent<GameControle>().RespawnGame();
                    }
                    else
                    {
                        GameControle.GetComponent<GameControle>().StopGame();
                        print("All Team Dead");
                    }
                    break;
                }
            case EStatePlayerBall.Standby:
                {
                    if (Input.GetButtonDown("Start_P" + m_iPlayerId))
                    {
                        bStart = true;
                    }
                    if (bStart)
                    {
                        GameControle.GetComponent<GameControle>().RestartGame();
                    }
                    break;
                }
        }
    }
コード例 #4
0
    public void Restart()
    {
        eStateMove = EStatePlayerMove.Run;
        eStateBall = EStatePlayerBall.Idle;
        Charac.useGravity = false;
        iScore = 0;
        bStart = false;
        this.transform.FindChild("Shield").GetComponent<ShieldScript>().ResetShield();
        Charac.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY;
        Charac.drag = CharacDrag;
        tPlayerAnimator.SetInteger("Dir", 0);

        IgnoreBallsCollisions(false);
    }
コード例 #5
0
 public void Respawn()
 {
     if (Ball != null)
     {
         Ball.GetComponent<BallControl>().Launch(TestBallCurve());
     }
     eStateMove = EStatePlayerMove.Run;
     eStateBall = EStatePlayerBall.Idle;
     Charac.useGravity = false;
     bStart = false;
     this.transform.FindChild("Shield").GetComponent<ShieldScript>().ResetShield();
     Charac.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY;
     Charac.drag = CharacDrag;
     IgnoreBallsCollisions(false);
 }
コード例 #6
0
 public void InitSmash()
 {
     eStateBall = EStatePlayerBall.Smash;
     SmashTimer = MaxShootingTime;
 }