示例#1
0
        /**
         * Launch player move if player can move
         */
        private void LaunchMoveMechanic()
        {
            isMoving = true;

            //FX wheels particule
            moveParticle.launchParticle();

            //The next tile position is
            Vector3Int nextPos = new Vector3Int(playerPath[tileIndex].X, 0, playerPath[tileIndex].Y);


            if (Mathf.Abs(transform.position.x - nextPos.x) < 0.001f && Mathf.Abs(transform.position.z - nextPos.z) < 0.001f)
            {
                //si on arrive à la tile finale où le player peut se rendre
                if (tileIndex == playerPath.Count - 1)
                {
                    this.transform.position = new Vector3(nextPos.x, this.transform.position.y, nextPos.z);
                    playerCanMove           = false;
                    isMoving  = false;
                    tileIndex = 0;
                    //FX wheels particule
                    moveParticle.stopParticle();
                    StartCoroutine(LaunchActionsInNewNode());  //Attends avant de permettre un autre move (pour ralentir le rythme)
                }
                else if (tileIndex < playerPath.Count - 1)
                {
                    tileIndex++;    //on passe à la tile suivante tant qu'on a pas atteint la dernière
                }
            }
            else
            {
                float ratio = (float)tileIndex / (playerPath.Count - 1);                                                                                            //Ratio between 0 and 1, 0 for the closest and 1 for the final one
                ratio = playerMoveCurve.Evaluate(ratio);                                                                                                            //Linked to the curve to modify it as we want
                float speed = playerSpeed * ratio;                                                                                                                  //Link ratio to modify speed
                transform.position = Vector3.MoveTowards(transform.position, new Vector3(nextPos.x, this.transform.position.y, nextPos.z), speed * Time.deltaTime); //Go to next tile
            }
        }
示例#2
0
 public void StopVisualEffect()
 {
     playerKillerInstinct.stopParticle();
     playerFastShoes.stopParticle();
     playerCounter.stopParticle();
 }