Esempio n. 1
0
        void Update()
        {
            if (activePlayer && !activePlayer.GetTurnEnd())
            {
                nextTurn();
            }

            if (activePlayer.HasActionLeft())
            {
                actionsLeft.color = new Color(0, 0, 1, .2f);
            }
            else
            {
                actionsLeft.color = new Color(1, 0, 0, .2f);
            }

            if (activePlayer.creature.isEnemy)
            {
                hotbar.enabled = false;
            }
            else
            {
                hotbar.enabled = true;
            }

            for (int i = 0; i < enemies.Count; i++)
            {
                if (enemies[i] == null)
                {
                    enemies.RemoveAt(i);
                }
            }

            if (enemies.Count == 0)
            {
                WinCondition();
            }
            if (playerUnits.Count == 0)
            {
                LoseCondition();
            }
        }
        // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
        override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            if (possible == null)
            {
                possible = ms.GetPossible(creature.movementLeft);
            }

            if (!ms.notMoving)
            {
                possible = ms.GetPossible(creature.movementLeft);
            }
            else if (possible != null)
            {
                ms.ShowPossible(possible);
            }
            brain.outline.OutlineColor = Color.blue;
            Ray        ray = brain.cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, brain.tileMapLayerMask))
            {
                Tile endTile = hit.collider.GetComponent <Tile>();
                brain.tileIndictor.transform.position = endTile.GetCenterOfTile();
                if (endTile.unitOnTile == null && Input.GetButtonDown("Fire1") && possible != null)
                {
                    bool a = false;
                    foreach (Tile tile in possible)
                    {
                        if (endTile == tile)
                        {
                            a = true;
                        }
                    }

                    if (a)
                    {
                        if (EventSystem.current.IsPointerOverGameObject())
                        {
                            return;
                        }
                        ms.Move(endTile, true);
                    }
                }
            }
            if (brain.HasActionLeft())
            {
                if (abilitySelector.currentlySelectedNum > 0)
                {
                    if (ms.finishedMoving)
                    {
                        animator.SetInteger("Ability", abilitySelector.currentlySelectedNum - 1);
                        animator.SetBool("UseAbility", true);
                        abilitySelector.ResetAbilitySelection(-1);
                        ms.finishedMoving = false;
                    }
                }
            }

            if (Input.GetButtonDown("Next"))
            {
                brain.isMyTurn = false;
            }
        }