Exemple #1
0
        /// <summary>
        /// 歩ける数
        /// </summary>
        /// <param name="count"></param>
        public void GetMoveCount(int count)
        {
            PlayerState = PlayerActionState.move;
            moveCount   = count;

            moveCountText.text = moveCount.ToString();
        }
Exemple #2
0
    //开新线程,监控状态
    IEnumerator AnimationStateMachine()
    {
        PlayerActionState state = PlayerActionState.WAITING;

        while (Application.isPlaying)
        {
            if (!Input.anyKey || Vector3.Magnitude(navAgent.velocity) == 0)
            {
                state = PlayerActionState.WAITING;
            }
            //if moving
            if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0 || Vector3.Magnitude(navAgent.velocity) > 0)
            {
                if (Input.GetAxisRaw("Vertical") != 0 || Input.GetAxisRaw("Horizontal") != 0)
                {
                    navAgent.isStopped = true;
                }

                transform.LookAt(transform.position + new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")));
                state = PlayerActionState.MOVING;
            }
            UpdateActionState(state);

            yield return(null);
        }
    }
Exemple #3
0
    void UpdateActionState(PlayerActionState state)
    {
        PlayerActionState previousActionState = _CurrentPlayerActionState;

        _CurrentPlayerActionState = state;
        if (previousActionState == state)
        {
            return;
        }
        switch (CurrentPlayerActionState)
        {
        case PlayerActionState.WAITING:
            animator.SetBool("isMoving", false);
            //repate watting Anition
            InvokeRepeating("watingAnmation", 0, 8.0f);
            break;

        case PlayerActionState.MOVING:
            if (previousActionState == PlayerActionState.WAITING)
            {
                CancelInvoke("watingAnmation");
            }
            animator.SetBool("isMoving", true);
            break;
        }
    }
Exemple #4
0
    private void Update()
    {
        dead = CheckDeath();
        CheckNearDeath();

        if (!dead)
        {
            runTime += Time.deltaTime;

            CountDown();
            CheckDirection();

            deathSoundPlayed = false;

            if (GetPause() &&
                pauseState.instance.GetCanPause())
            {
                if (pauseState.instance.GetPauseState() == PAUSESTATE.UNPAUSED)
                {
                    pauseState.instance.SetPauseState(PAUSESTATE.PAUSED);
                    menu.ShowPauseMenu();
                    spawnEnemies.instance.SetCanSpawnMinions(false);
                    trackConstructor.instance.SetCanMove(false);
                }
                else
                {
                    pauseState.instance.SetPauseState(PAUSESTATE.UNPAUSED);

                    if (menu.pauseUI.activeSelf)
                    {
                        menu.ResumeGame();
                    }
                }
            }

            if (pauseState.instance.GetPauseState() == PAUSESTATE.PAUSED)
            {
                anim.PauseAnimations();
            }
            else
            {
                anim.ContinueAnimations();
            }
        }
        else
        {
            moveState   = PlayerMoveState.DEAD;
            actionState = PlayerActionState.DEAD;
            spawnEnemies.instance.SetCanSpawnMinions(false);
            trackConstructor.instance.SetCanMove(false);

            if (!deathSoundPlayed)
            {
                sound.PlaySound(SOUND.DEATH);
                deathSoundPlayed = true;
            }

            audioManager.instance.CrossFade(MUSIC.PLAYER_DEATH);
        }
    }
Exemple #5
0
    public void SwitchActionState(PlayerActionState a)
    {
        switch (a)
        {
        case PlayerActionState.None:
            if (currentActionPoints > 0)
            {
                TileMap.Instance.Dijkstra(currentNode, maxSteps);
            }
            PlayerUnitsController.Instance.lineRenderer.gameObject.SetActive(false);
            Debug.Log("Turn Off");

            break;

        case PlayerActionState.MoveSelection:
            if (currentActionPoints > 0)
            {
                TileMap.Instance.Dijkstra(currentNode, maxSteps);
                PlayerUnitsController.Instance.lineRenderer.gameObject.SetActive(true);
            }
            break;

        case PlayerActionState.Aiming:
            TileMap.Instance.Clear();
            break;
        }

        actionState = a;
    }
Exemple #6
0
        void Move()
        {
            oneBeforePos = nowPos;
            nowPos       = nextPos;

            if (moveCount > 0)
            {
                moveCount--;
            }

            moveCountText.text = moveCount.ToString();

            transform.position = mapPosLis[nowPos.y][nowPos.x].transform.localPosition;

            CheckEnd();

            if (moveCount <= 0)
            {
                PlayerState = PlayerActionState.squareAction;
                ExecuteAction();

                mapChanged.TurnDown();
                return;
            }
        }
Exemple #7
0
    IEnumerator MoveNextTile()
    {
        //Remove the old first node and move us to that position
        currentPath.RemoveAt(0);

        SetMoveDestination(currentPath[0].transform.position, 0.45f);

        //transform.position = currentPath[0].transform.position;
        transform.rotation = currentPath[0].transform.rotation;

        currentNode = currentPath[0];

        if (currentPath.Count == 1)
        {
            //Next thingy in path would be our ultimate goal and we're standing on it. So make the path null to end this
            currentPath = null;
            actionState = PlayerActionState.None;
            StageUIController.Instance.playerMoveButton.interactable = true;
            if (unitState == UnitState.Selected && currentActionPoints > 0)
            {
                TileMap.Instance.Dijkstra(currentNode, maxSteps);
            }
        }

        yield return(new WaitForSeconds(0.5f));
    }
 private void StartCallingBlobsBack()
 {
     StopCurrentAction();
     state = PlayerActionState.CallingBack;
     callIndicator.SetActive(true);
     playerAnimator.SetTrigger("Recall");
     currentActionRoutine = StartCoroutine(CallBlobsBack());
 }
 public PlayerDataComponent() : base()
 {
     actionState         = PlayerActionState.Default;
     usableObject        = null;
     speedModifierObject = null;
     trashCount          = 0;
     closeWindows        = new HashSet <WindowComponent>();
     id = -1;
 }
 public void checkDeath()
 {
     if (player.health <= 0)
     {
         actionState   = PlayerActionState.Dead;
         rb2d.velocity = Vector2.zero;
     }
     else
     {
         actionState = PlayerActionState.Idle;
     }
 }
Exemple #11
0
    // Attempts to retrieve the ActionState pairing for a particular GameState. If the ActionState is not in the Map, then it is added.
    private PlayerActionState getActionState(double[] stateVals)
    {
        List <NodeDistance <KDTreeNode <PlayerActionState> > > actionStates = actionStateMap.Nearest(stateVals, GameState.voxel_radius * 0.1);

        if (actionStates.Count < 1)
        {
            PlayerActionState newState = new PlayerActionState(new GameState(stateVals));
            actionStateMap.Add(stateVals, newState);
            return(newState);
        }

        return(actionStates[0].Node.Value);
    }
Exemple #12
0
 public void Move()
 {
     TileMap.Instance.Clear();
     if (actionState == PlayerActionState.MoveSelection &&
         actionState != PlayerActionState.Moving &&
         currentPath != null &&
         currentActionPoints > 0)
     {
         actionState = PlayerActionState.Moving;
         StartCoroutine(MoveCoroutine());
         currentActionPoints--;
     }
 }
    public void cooldown()
    {
        if (healthFlashTimer > 0.0f)
        {
            healthFlashTimer -= Time.deltaTime;

            if (healthFlashTimer <= 0.0f)
            {
                GetComponent <SpriteRenderer>().color = new Vector4(1, 1, 1, 1);
            }
        }

        if (dashLength > 0.0f)
        {
            dashLength -= Time.deltaTime;

            if (dashLength <= 0.0f)
            {
                moveState        = PlayerMoveState.Idle;
                player.isDashing = false;
                GetComponent <SpriteRenderer>().color = new Vector4(1, 1, 1, 1);
            }
        }

        if (dashTimer > 0.0f)
        {
            dashTimer -= Time.deltaTime;
        }

        if (attackTimer > 0.0f)
        {
            attackTimer -= Time.deltaTime;

            if (attackTimer <= 0.0f)
            {
                actionState = PlayerActionState.Idle;
            }
        }

        if (duckTimer > 0.0f)
        {
            duckTimer -= Time.deltaTime;

            if (duckTimer <= 0.0f)
            {
                blockArea.enabled = true;
                duckTimer         = 0.25f;
            }
        }
    }
    private void StopCurrentAction()
    {
        if (currentActionRoutine != null)
        {
            StopCoroutine(currentActionRoutine);
            currentActionRoutine = null;
        }

        switch (state)
        {
        case PlayerActionState.CallingBack:
            callIndicator.SetActive(false);
            break;
        }
        state = PlayerActionState.NoAction;
    }
 public PlayerObject(GameScene owner, Color defaultColor, Rectangle rectData, string drawKeyword)
 {
     this.owner = owner;
     this.textureList = new Dictionary<string, Texture2D>();
     this.color = defaultColor;
     this.rectData = rectData;
     this.drawKeyword = drawKeyword;
     this.playerLife = 3;
     this.strikeCount = 0;
     this.stageSelectUfoKey = 0;
     this.nowBateerState = PlayerActionState.Stand;
     this.battingHitTime = 0;
     this.stageUfoCount = 100;
     this.nowBattingResult = BattingResult.NoSwing;
     this.targetPos = new Vector2(10, 560);
 }
Exemple #16
0
    public void Shoot(Node v)
    {
        if (actionState == PlayerActionState.Aiming)
        {
            TileMap.Instance.Clear();
            v.HighlightField(Color.red);

            if (Input.GetMouseButtonUp(0))
            {
                if (equippedWeapon != null && currentActionPoints > 0)
                {
                    equippedWeapon.Fire(currentNode, v, "Enemy");
                    currentActionPoints--;
                    actionState = PlayerActionState.None;
                }
            }
        }
    }
Exemple #17
0
        /// <summary>
        /// MapCreateよりも遅く実行する
        /// </summary>
        /// <returns></returns>
        IEnumerator Start()
        {
            // 処理順の調整
            yield return(new WaitForSeconds(0.1f));

            InitSetValue();

            NextSquare();

            PlayerState = PlayerActionState.actionSelect;

            mapChanged = FindObjectOfType <UI.MapChanged>();

            mapChanged.moveEvent += (taxiMoveCounts) =>
            {
                GetMoveCount(taxiMoveCounts);
                mapChanged.TurnUp();
            };
        }
    public void checkAction()
    {
        if (Input.GetKeyDown(attackKey) || Input.GetKeyDown(joyAttackKey))
        {
            if (attackTimer <= 0.0f)
            {
                //combat.attack(weaponSpawn, weapon, attackTarget);
                attackTimer = player.attackDelay;
            }

            if (attackTimer > 0.0f)
            {
                actionState = PlayerActionState.Attacking;
            }
            else
            {
                actionState = PlayerActionState.Idle;
            }
        }
    }
Exemple #19
0
    // Records observed movement of the Player to the Map
    public void recordAction(GameObjectState prevState, GameObjectState currState)
    {
        if (prevState == null || currState == null)
        {
            return;
        }

        double[] prevVoxels = prevState.getVoxelStateVals();
        double[] currVoxels = prevState.getVoxelStateVals();

        PlayerActionState prevActionState = getActionState(prevVoxels);
        PlayerActionState currActionState = getActionState(currVoxels);

        Vector3         rHandPos    = currState.rHandPos - prevState.rHandPos;
        Vector3         rHandVel    = currState.rHandVel - prevState.rHandVel;
        Vector3         paddlePos   = currState.paddlePos - prevState.paddlePos;
        Vector3         paddleVel   = currState.paddleVel - prevState.paddleVel;
        GameObjectState stateChange = new GameObjectState(rHandPos, rHandVel, paddlePos, paddleVel, currState.targetPos, currState.targetVel, currState.deltaTime);

        prevActionState.addAction(currVoxels, stateChange);
    }
    public void cooldown()
    {
        if (dashLength > 0.0f)
        {
            dashLength -= Time.deltaTime;

            if (dashLength <= 0.0f)
            {
                moveState        = PlayerMoveState.Idle;
                player.isDashing = false;
            }
        }

        if (dashTimer > 0.0f)
        {
            dashTimer -= Time.deltaTime;
        }

        if (attackTimer > 0.0f)
        {
            attackTimer -= Time.deltaTime;

            if (attackTimer <= 0.0f)
            {
                actionState = PlayerActionState.Idle;
            }
        }

        if (duckTimer > 0.0f)
        {
            duckTimer -= Time.deltaTime;

            if (duckTimer <= 0.0f)
            {
                blockArea.enabled = true;
                duckTimer         = 0.25f;
            }
        }
    }
 private void Initialize()
 {
     playerCamera   = Camera.main;
     state          = PlayerActionState.NoAction;
     followingBlobs = new List <BlobBase>();
 }
Exemple #22
0
 void OnEmptyClick(System.Type type)
 {
     PlayerActionState.Set(ActionState.Idle);
 }
 public void strikeCheck()
 {
     this.nowBateerState = PlayerActionState.Stand;
     this.strikeCount++;
     if (this.strikeCount >= 3)
     {
         this.strikeCount = 0;
         this.playerLife--;
         this.playerLoseCheck();
     }
 }
Exemple #24
0
 /// <summary>
 /// 重置所有单位的行动状态
 /// </summary>
 public void ResetActionState()
 {
     if (this.ActionState != PlayerActionState.AllDead)
     {
         //重置英雄行动状态
         Hero.ResetActionState();
         //重置所有部队的行动状态
         for (int i = 0; i < Corps.Length; i++)
         {
             Corps[i].ResetActionState();
         }
         //修改队伍行动状态
         this.ActionState = PlayerActionState.AllReady;
     }
 }
 private void StartThrowingBlobs()
 {
     StopCurrentAction();
     state = PlayerActionState.Throwing;
     currentActionRoutine = StartCoroutine(ThrowBlobs());
 }
 private void buttingResult()
 {
     if (this.nowGameState == GameMainState.BallStart)
     {
         this.swingTime++;
         if (Input.GetKeyState(Keys.Z) == KeyResultState.PushedNow && swingTime > 5)
         {
             this.nowGameState = GameMainState.BallAction;
             this.nowBateerState = PlayerActionState.Swing;
             this.swingTime = 0;
         }
     }
 }
Exemple #27
0
 public void SetActionState(PlayerActionState set)
 {
     actionState = set;
 }
 private void buttingSwing()
 {
     if (this.nowGameState == GameMainState.BallAction && this.nowBateerState == PlayerActionState.Swing)
     {
         this.battingHitTime++;
         if (this.battingHitTime >= 15)
         {
             this.nowBateerState = PlayerActionState.SwingResult;
             this.battingHitTime = 0;
             this.strikeCheck();
             this.nowBattingResult = BattingResult.NoSwing;
         }
     }
 }
Exemple #29
0
 /// <summary>
 /// 队伍执行下一个动作
 /// </summary>
 /// <param name="turn">当前回合数</param>
 /// <param name="enemy">敌人(怪物队伍)</param>
 /// <returns>本次行动日志</returns>
 public string DoNextAction(int turn, MonsterTeam enemy)
 {
     Unit nextActionUnit = null;
     //根据队伍行动状态选取下一个行动单位并执行动作
     if (this.ActionState == PlayerActionState.AllReady)
     {
         //英雄行动
         //修改队伍行动状态为英雄行动结束
         this.ActionState = PlayerActionState.HeroDone;
         if (Hero.ActionState != UnitActionState.Dead)
         {
             //执行英雄动作
             nextActionUnit = Hero;
             //return Hero.Action(turn, enemy);
         }
     }
     else if (this.ActionState == PlayerActionState.HeroDone)
     {
         //部队行动
         double maxValue = 0;
         double randValue = 0;
         //Corps nextCorps = null;
         int count = 0;
         //随机选取未行动的部队行动(分配随机数,选取随机数最大的部队准备执行动作)
         for (int i = 0; i < Corps.Length; i++)
         {
             if (Corps[i].ActionState == UnitActionState.Ready)
             {
                 count++;
                 randValue = RandomBuilder.GetDouble();
                 if (randValue > maxValue)
                 {
                     nextActionUnit = Corps[i];
                     maxValue = randValue;
                 }
             }
         }
         //如果为最后一个未行动部队,修改队伍行动状态为全部单位行动结束
         if (count <= 1)
         {
             this.ActionState = PlayerActionState.AllDone;
         }
     }
     //如果无可行动单位,返回空字符串
     if (nextActionUnit == null)
     {
         return "";
     }
     else
     {
         //执行该单位动作
         return nextActionUnit.Action(turn, enemy);
     }
 }