Exemplo n.º 1
0
        // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
        override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            abilityToUse = animator.GetInteger("Ability");
            if (brain.creature.abilityContainer.IsAoe(abilityToUse))
            {
                lm = brain.selectingGroundLayerMask;
            }
            else
            {
                brain.creature.abilityContainer.StopAoe();
                lm = brain.selectingCreaturesLayerMask;
            }
            Ray        ray = brain.cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100, lm))
            {
                brain.creature.abilityContainer.HighlightTarget(abilityToUse, hit);
                if (Input.GetButtonDown("Fire1"))
                {
                    brain.creature.abilityContainer.UseAbility(abilityToUse, hit);
                    animator.SetBool("UseAbility", false);
                }
            }

            if (Input.GetButtonDown("Cancel") || Input.GetButtonDown("Fire2"))
            {
                animator.SetBool("UseAbility", false);
            }

            if (abilitySelector.currentlySelectedNum > 0)
            {
                animator.SetInteger("Ability", abilitySelector.currentlySelectedNum - 1);
                animator.SetBool("UseAbility", true);
                abilitySelector.ResetAbilitySelection(-1);
            }
        }
        // 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;
            }
        }