예제 #1
0
 public void Fencing_StopFencing(bool shouldStopFencing)
 {
     if (shouldStopFencing)
     {
         PlayerState = PlayerControllerState.movingAround;
     }
 }
예제 #2
0
 public void MovingAround_StartFencing(bool shouldStartFencing)
 {
     if (shouldStartFencing)
     {
         PlayerState = PlayerControllerState.fencing;
     }
 }
    public static FighterControllerState DetermineFighterControllerState(FighterController fighterController)
    {
        FighterControllerState fighterControllerState = null;

        if (fighterController.IsPlayerOne() || GameData.GetPlayers() == 2)
        {
            fighterControllerState = new PlayerControllerState();
        }
        else
        {
            switch (GameData.GetComputerDifficulty())
            {
            case Difficulty.Easy:
                fighterControllerState = new EasyAiControllerState();
                break;

            case Difficulty.Medium:
                fighterControllerState = new MediumAiControllerState();
                break;

            case Difficulty.Hard:
                fighterControllerState = new HardAiControllerState();
                break;
            }
        }

        fighterControllerState.Init(fighterController);
        return(fighterControllerState);
    }
예제 #4
0
 public void StartPlaningBuilding(BuildingData building)
 {
     state = PlayerControllerState.BuildingMode;
     buildingSystem.StartPlaning(building.placerPrefab);
     if (currentOpenBubbleMenu != null)
     {
         currentOpenBubbleMenu.Hide();
     }
 }
예제 #5
0
    void Update()
    {
        #region TimerMaintenance
        jumpCooldownTmp -= Time.deltaTime;
        #endregion

        #region GatherInput
        if (this.isThisMachinesPlayer)
        {
            this.gamepadState = GamePad.GetState(this.padIndex);
        }
        this.controllerMoveDirection = GamePad.GetAxis(GamePad.Axis.LeftStick, this.padIndex);
        this.controllerLookDirection = GamePad.GetAxis(GamePad.Axis.RightStick, this.padIndex);
        #endregion

        #region SettingPlayerState
        if (this.gamepadState.LeftTrigger > 0.20f)
        {
            this.playerState = PlayerControllerState.aiming;
        }
        else if (this.gamepadState.LeftStick)
        {
            this.playerState = PlayerControllerState.running;
        }
        else
        {
            this.playerState = PlayerControllerState.walking;
        }
        #endregion

        Vector3 forward = this.myCamera.transform.TransformDirection(Vector3.forward);
        forward            = forward.normalized;
        this.moveDirection = this.controllerMoveDirection.y * forward + this.controllerMoveDirection.x * new Vector3(forward.z, 0, -forward.x);

        AdjustCamera();

        #region RunningActionByState
        forward            = this.myCamera.transform.TransformDirection(Vector3.forward);
        forward            = forward.normalized;
        this.moveDirection = this.controllerMoveDirection.y * forward + this.controllerMoveDirection.x * new Vector3(forward.z, 0, -forward.x);
        moveDirection     *= this.baseSpeed;
        switch (this.playerState)
        {
        case PlayerControllerState.walking:
            break;

        case PlayerControllerState.running:
            moveDirection *= this.runSpeedMultiplier;
            break;

        case PlayerControllerState.aiming:
            moveDirection *= this.aimSpeedMultiplier;
            break;
        }
        #endregion

        #region Movement
        if (this.moveDirection.magnitude > 0.05f)
        {
            this.GetComponent <Rigidbody>().velocity = Vector3.Lerp(this.GetComponent <Rigidbody>().velocity, this.moveDirection, this.velocityDampingSpeed);
            this.transform.forward = Vector3.Lerp(this.transform.forward, this.GetComponent <Rigidbody>().velocity.normalized, this.velocityDampingSpeed);
            this.GetComponent <Rigidbody>().angularVelocity = Vector3.Lerp(this.GetComponent <Rigidbody>().angularVelocity, Vector3.zero, this.velocityDampingSpeed);
        }
        #endregion
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        cameraController.MoveCamera(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), Input.GetAxis("Mouse ScrollWheel"));


        #region input

        if (Input.GetKeyDown(KeyCode.B))
        {
            uIManager.ToogleBuildingPanel();
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            if (economyActive)
            {
                ExitEconomyMenagementMode();
            }
            else
            {
                EnterEconomyMenagementMode();
            }
        }



        #endregion

        #region Handle states in update

        switch (state)
        {
        case PlayerControllerState.Default:



            if (Input.GetMouseButtonDown(0))
            {
                if (!economyActive)
                {
                    if (!Utility.HitsUI(Input.mousePosition))
                    {
                        if (currentOpenBubbleMenu != null)
                        {
                            currentOpenBubbleMenu.Hide();
                        }
                    }
                    layerMask = 1 << buildingsLayer;

                    ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                    if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
                    {
                        //all buildings need to have buildingMenu attached
                        BubbleMenu bubbleMenu = hit.collider.GetComponent <BubbleMenu>();
                        if (bubbleMenu != null)
                        {
                            currentOpenBubbleMenu = bubbleMenu;
                            currentOpenBubbleMenu.Show();
                        }
                    }
                }
            }

            break;

        case PlayerControllerState.BuildingMode:

            layerMask = 1 << groundLayer;

            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
            {
                buildingSystem.PlanBuilding(hit.point);
            }

            if (Input.GetMouseButtonDown(0))
            {
                if (!Utility.HitsUI(Input.mousePosition))
                {
                    Debug.Log("click");
                    buildingSystem.PlaceBuilding(hit.point);
                }
            }
            else if (Input.GetMouseButtonDown(1))
            {
                state = PlayerControllerState.Default;
                buildingSystem.StopPlaning();
            }

            break;


            #endregion
        }
    }
예제 #7
0
 public void StopPlaningBuilding()
 {
     state = PlayerControllerState.Default;
     buildingSystem.StopPlaning();
 }
예제 #8
0
 void Start()
 {
     PlayerState = PlayerControllerState.movingAround;
 }
예제 #9
0
 /// RequestStartCallBack is used to add functionality on start.
 public void RequestStartCallback(PlayerControllerState state, Action callback)
 {
     actions[(int)state].onStart += callback;
 }
예제 #10
0
 private void SetState(PlayerControllerState state)
 {
     actions[(int)currentPlayerState].onEnd?.Invoke();
     currentPlayerState = state;
     actions[(int)currentPlayerState].onStart?.Invoke();
 }
예제 #11
0
 public void SetPlayerControllerState(PlayerControllerState newState)
 {
     ControllerState = newState;
     //Set the material from the visualizations array.
     renderer.sharedMaterial = Visualization.First(x => x.State == newState).Material;
 }