Update() private méthode

private Update ( ) : void
Résultat void
Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        currentState.Update();
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        currentState.Update();

        horizontalInput = Input.GetAxis("Horizontal");

        if (horizontalInput != 0)
        {
            GetComponent <SpriteRenderer>().flipX = horizontalInput < 0;
        }

        var amt = 4;

        if (!(currentState is SwingingState))
        {
            // Return to normal rotation
            // var curAngle = this.transform.rotation.eulerAngles.z;
            // if(curAngle != 0){
            //  var newAngle = curAngle + ((curAngle > 0) ?  -amt : amt);
            //  newAngle = (curAngle > 0) ? Mathf.Floor(newAngle) : Mathf.Ceil(newAngle);
            //  if(curAngle > 0 && newAngle < 0 || curAngle < 0 && newAngle > 0){
            //      newAngle = 0;
            //  }

            this.transform.rotation = Quaternion.Euler(0, 0, 0);
            // }
        }
    }
Exemple #3
0
    private void Update()
    {
        //state Update
        currentState.Update();

        cc.Move(move * Time.deltaTime);
    }
    /// <summary>
    /// updates the player should make every frame
    /// </summary>
    void Update()
    {
        staminaPercentage = new Vector3(stamina / 100, 1, 1);
        StaminaBar.rectTransform.localScale = staminaPercentage;
        stamina          = Mathf.Clamp(stamina, 0, 100);
        healthPercentage = new Vector3(Health / 100, 1, 1);
        HPBar.rectTransform.localScale = healthPercentage;
        Health = Mathf.Clamp(Health, 0, 100);

        if (state != null)
        {
            PlayerState newState = state.Update();

            SwitchPlayerState(newState);
        }
        if (stamina < 100)
        {
            StaminaRegen();
        }
        dodgeCooldown -= Time.deltaTime;
        if (didAction == true)
        {
            lastAction += Time.deltaTime;
        }
    }
 void Update()
 {
     if (!frozen)
     {
         currentState.Update();
     }
 }
        public void Update()
        {
            var cam = entity.scene.camera;

            if (transform.position.X > cam.transform.position.X + cam.bounds.width / 2)
            {
                RegularStateMachine = new DeadDeadNotGoodState();
            }

            var nextStateMachine = RegularStateMachine.Update(this);
            var nextSpeedMachine = SpeedState.Update(this);

            if (nextStateMachine != RegularStateMachine)
            {
                RegularStateMachine.End(this);
                RegularStateMachine = nextStateMachine;
                RegularStateMachine.Begin(this);
            }

            if (Input.IsStopping())
            {
                SpeedState.AnimationFpsModifier = 0.33f;
                SpeedState.VelocityModifier     = 0.33f;
            }

            else if (Input.IsStopping())
            {
                SpeedState.AnimationFpsModifier = 1f;
                SpeedState.VelocityModifier     = 1f;
            }
        }
Exemple #7
0
 void Update()
 {
     if (!gameEnd)
     {
         state.Update();
     }
 }
    public void FixedUpdate()
    {
        playerController.Update();

        // pass player controller
        currentState.HandleInput(playerController);
        currentState.Update();
    }
 void Update()
 {
     currentPlayerState.Update(this);
     healthBar.SetHealth(health);
     if (health <= 0)
     {
         SceneManager.LoadScene("MainMenu");
     }
 }
Exemple #10
0
    static int Update(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        PlayerState obj = (PlayerState)LuaScriptMgr.GetNetObjectSelf(L, 1, "PlayerState");

        IM.Number arg0 = (IM.Number)LuaScriptMgr.GetNetObject(L, 2, typeof(IM.Number));
        obj.Update(arg0);
        return(0);
    }
Exemple #11
0
 // Update is called once per frame
 /// <summary>
 /// this function is called every frame and runs the player state logic
 /// </summary>
 void Update()
 {
     //print(playerState);
     if (playerState != null)
     {
         PlayerState newState = playerState.Update();
         SwitchPlayerState(newState);
     }
 }
Exemple #12
0
 public void Update(double dt)
 {
     StateChangeCheck();
     if (player.Controller.NeedJump())
     {
         current.Jump();
     }
     current.Update(dt);
     current.AddTime(dt);
 }
Exemple #13
0
 // Update is called once per frame
 void Update()
 {
     currentState.Update(this);
     AnyStateUpdate();
     //Debug.Log(currentState);
     //Debug.Log(actualWeapon);
     //Debug.Log("Gliding: " + gliding);
     //Debug.Log(readyToGlind);
     //Debug.Log(onGround);
 }
    void Update()
    {
        PlayerState nextState = currentState.Update();

        if (nextState != currentState)
        {
            currentState.Finish();
            currentState = nextState;
            nextState.Start();
        }
        correctCameraRotation();
    }
Exemple #15
0
 void Update()
 {
     if (curState != null)
     {
         PlayerStateEnum nextState = curState.Update();
         if (nextState != curState.state)
         {
             curState.Exit();
             curState = GetState(nextState);
             curState.Enter();
         }
     }
 }
Exemple #16
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //base.FixedUpdate();
        //Debug.Log(state);
        PlayerState returnState = state.Update(this);

        if (returnState != null)
        {
            state = returnState;

            state.Enter(this);
        }
    }
    void Update()
    {
        LookAround();

        PlayerState newState = playerState.Update();

        SwitchPlayerState(newState);

        if (Input.GetButtonDown("Ability"))
        {
            UseAbility();
        }

        ManaRegen();
    }
Exemple #18
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Heal"))
        {
            Heal();
        }
        //text.text = "Attack1 Charges: " + (int) attack1Charges + " " + "Attack2 Charges: " + (int) attack2Charges + " " + "Dash Charges: " + (int) dashCharges;
        //		Debug.Log (text.text);

        //register all the inputs that need to be dynamically tracked
        //movement key inputs
        movementInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
        //mouse position
        Ray        camRay = playerCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit floorHit;

        if (Physics.Raycast(camRay, out floorHit, playerCamera.farClipPlane, LayerMask.GetMask("MouseRaycast")))
        {
            Vector3 p2m = floorHit.point - transform.position;
            p2m.y         = 0f;
            playerToMouse = p2m.normalized;
        }

        //Animate
        currentState.Animate();

        //carry out state-specific orders
        currentState.Update();


        if (stateEnded)
        {
            if (nextState == null)
            {
                this.nextState = currentState.HandleInput();
            }
            stateEnded = false;
        }

        if (this.GetComponent <Health>().currentHealth <= 0)
        {
            this.currentState.Exit();
            LoadOnClick.StaticLoadSceneByName("MainMenu");
        }
    }
Exemple #19
0
    private void Update()
    {
        if (respawnFreeze || gameManager.gameState == GameManager.GameState.cutscene)
        {
            return;
        }

        CoyoteJumpTimer();

        returnedState = currentState.Update(this, Time.deltaTime);

        if (returnedState != null)
        {
            StateSwap();
        }

        ChooseColor();
    }
        public void Update(GameTime time)
        {
            var newState = current_state.Update(time);

            // Transision states if needed
            if (next_state != null)
            {
                newState   = next_state;
                next_state = null;
            }

            if (newState != null)
            {
                current_state.OnExit();
                newState.OnEnter();
                current_state = newState;
            }
        }
    void Update()
    {
        changedState = false;
        input.GetInput();
        PlayerState newState1 = state.HandleInput(this, input);
        PlayerState newState2 = state.Update(this, input);

        if (newState1 != null && !changedState)
        {
            changedState = true;
            state        = newState1;
            state.StateEnter(this);
        }
        else if (newState2 != null && !changedState)
        {
            changedState = true;
            state        = newState2;
            state.StateEnter(this);
        }
    }
Exemple #22
0
    void FixedUpdate()
    {
        if (Input.GetKeyDown("1"))
        {
            SetState(0);
        }
        else if (Input.GetKeyDown("2"))
        {
            SetState(1);
        }
        else if (Input.GetKeyDown("3"))
        {
            SetState(2);
        }
        else if (Input.GetKeyDown("4"))
        {
            SetState(3);
        }

        _currentState.Update();
    }
Exemple #23
0
    void Update()
    {
        currentState.Update(this);

        grounded = isGrounded();

        Vector3 horizontalRayPosition = transform.position;

        horizontalRayPosition.y += 0.75f;

        RaycastHit horizontalHit;

        if (Physics.Raycast(horizontalRayPosition, transform.forward, out horizontalHit, 1.0f, LayerMask.GetMask("Ground")))
        {
            Debug.DrawRay(horizontalRayPosition, transform.forward, Color.red);
        }
        else
        {
            Debug.DrawRay(horizontalRayPosition, transform.forward, Color.green);
        }

        Vector3 verticalRayPosition = transform.position;

        verticalRayPosition   += transform.forward;
        verticalRayPosition.y += 1.0f;

        RaycastHit verticalHit;

        if (Physics.Raycast(verticalRayPosition, -transform.up, out verticalHit, 1.0f, LayerMask.GetMask("Ground")))
        {
            Debug.DrawRay(verticalRayPosition, -transform.up, Color.red);
        }
        else
        {
            Debug.DrawRay(verticalRayPosition, -transform.up, Color.blue);
        }
    }
Exemple #24
0
 private void Update()
 {
     UpdateDirection();
     state.Update();
 }
Exemple #25
0
 void Update()
 {
     currentState.Update(this);
 }
Exemple #26
0
 private void Update()
 {
     _state?.Update();
 }
Exemple #27
0
 void Update()
 {
     currentState.Update();
 }
Exemple #28
0
        protected override void Update(GameTime gameTime)
        {
            //Reject code from input
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                projectile.Spawn(ship.GetPlayer(), Allobject, gameTime);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.U))
            {
                ship.CU();
            }

            //Checks if ship is dead
            if (ship.Dead() && onetime)
            {
                keepPlaying = ship.keepPlaying;
                onetime     = false;
                ship.lose(playerName);
                this.Exit();
            }



            newState = Mouse.GetState();



            //CHECKS COLLISON with player
            for (int i = 1; i < Allobject.Count; i++)
            {
                Allobject[0].SAFCCollision(Allobject[i]);
            }

            ship.Update(gameTime);

            //Checks if projectile did a thing
            for (int i = 1; i < Allobject.Count; i++)
            {
                for (int j = 0; j < Allobject.Count; j++)
                {
                    Allobject[i].SAFCCollision(Allobject[j]);
                }
            }

            //Deletes stuff
            for (int i = 0; i < Allobject.Count; i++)
            {
                if ((Allobject[i].hit == true || Allobject[i].health <= 0))
                {
                    if (Allobject[i] is Player)
                    {
                        continue;
                    }
                    if (Allobject[i] is Asteroid)
                    {
                        ship.GetPlayer().score += 10;
                        ship.GetPlayer().money += 10;
                        asteroid.SpawnCheck(Allobject[i] as Asteroid, Allobject);
                    }
                    Allobject.RemoveAt(i);
                }
            }

            //CHECKS size of astriod



            //updates code
            for (int i = 0; i < Allobject.Count; i++)
            {
                Allobject[i].Update(gameTime);


                //LOOPS ALL OBJS
                if (Allobject[i].position.X > ScreenX + ScreenOffSet)
                {
                    Allobject[i].position.X = -ScreenOffSet;
                }

                else if (Allobject[i].position.X < -ScreenOffSet)
                {
                    Allobject[i].position.X = ScreenX + ScreenOffSet;
                }

                if (Allobject[i].position.Y > ScreenY + ScreenOffSet)
                {
                    Allobject[i].position.Y = -ScreenOffSet;
                }
                else if (Allobject[i].position.Y < -ScreenOffSet)
                {
                    Allobject[i].position.Y = ScreenY + ScreenOffSet;
                }
            }

            int count = 0;

            for (int i = 1; i < Allobject.Count; i++)//spawn more asteroids when there is none left
            {
                if (Allobject[i] is Asteroid)
                {
                    count++;
                }
            }
            if (count == 0)
            {
                for (int i = 0; i < 15; i++)
                {
                    asteroid.Spawn();    //spawn Asteroids
                }

                foreach (var obj in asteroid.GetSprite())
                {
                    Allobject.Add(obj);
                }
            }

            base.Update(gameTime);
        }
Exemple #29
0
 // Update is called once per frame
 public void Update()
 {
     playerState.Update();
 }
Exemple #30
0
 public void Update(GameTime gameTime)
 {
     state.Update(gameTime);
 }