Пример #1
0
        public void BeginTurn()
        {
            doingAction = false;
            UIManager._instance.ClearUnitList();
            onConfirm        = null;
            onCancelActions  = new List <UnityEngine.Events.UnityAction>();
            currentCharacter = currentCharacters[0];

            CameraFollow.target = currentCharacter.body.transform;
            BattleUIContainer.RefreshUnitView(currentCharacter);
            GameManager.SetControlMode(ControlsMode.Disabled);

            if (currentCharacter.aiBehaviour == null)
            {
                currentCharacter.anim.Play("Jump");
                UIManager._instance.MenuPanel.gameObject.SetActive(true);
                UIManager._instance.FocusMenuPanel(true);
                UIManager._instance.SetButtonsActive(new bool[] { true, !currentCharacter.TurnActionsPreformed[0], !currentCharacter.TurnActionsPreformed[0], !currentCharacter.TurnActionsPreformed[1], false, false, currentCharacters.Count > 1, currentCharacters.Count > 1, true, true });
            }
            else
            {
                currentCharacter.aiBehaviour.Think(currentCharacter.body.aiHandelerer, GameGrid.currentGrid);
                UIManager._instance.MenuPanel.gameObject.SetActive(false);
            }
        }
Пример #2
0
        public override void Begin()
        {
            base.Begin();
            Target.isOutside = false;
            List <Character> allAliveMinusMe = activator.GetEnemiesAtRange(activator.stats.attackRange);

            allAliveMinusMe.Remove(activator);
            if (activator.aiBehaviour == null)
            {
                UIManager._instance.unitList.gameObject.SetActive(true);
                UIManager._instance.SetUnitList(allAliveMinusMe);
            }
            if (allAliveMinusMe.Count != 0)
            {
                BattleUIContainer._instance.UnitView.SetDamagePreview(allAliveMinusMe[0].stats, activator.stats);
                BattleUIContainer.RefreshUnitView(allAliveMinusMe[0]);
            }

            Target.SetTargetList(allAliveMinusMe);

            GameManager.SetControlMode(ControlsMode.AttackTarget);
            List <GridPosition> Range = GameGrid.currentGrid.GetAllWalkableTileInRange(activator.Position, activator.stats.attackRange, true);

            RangeDisplayer._Main.DisplayRange(Range, RangeDisplayer.RangeType.Attack);


            UIManager._instance.FocusMenuPanel(false);
            UIManager._instance.SetButtonsActive(new bool[] { false, false, false, false, true, true, false, false, false });
        }
Пример #3
0
        public static void SetTarget(ITargetable target, bool show = true)
        {
            if (indicator == null)
            {
                indicator = UIManager._instance.CreateTargetIndicator(target.getGridPosition(), Color.red, true);
            }
            else
            {
                indicator.SetTarget(target.getGridPosition());
                indicator.SetColor(Color.red);
                indicator.SetShow(show);
            }

            currentTarget       = target;
            currentPosition     = target.getGridPosition();
            CameraFollow.target = target.GetTransform();

            if (Character.GetCharacterAtTile(currentPosition) != null)
            {
                BattleUIContainer.RefreshUnitView(Character.GetCharacterAtTile(currentPosition));
            }

            if (currentTargetList != null && currentTargetList.Contains(target))
            {
                SelectedIndex = currentTargetList.IndexOf(target);
            }
        }
Пример #4
0
 public void Initialize()
 {
     listOfTeams = Mission.currentMission.Teams;
     UIManager._instance.ShowWindow(UIManager.WindowType.GameUI);
     UIManager._instance.SetButtonsActive(new bool[] { false, false, false, false, false, false, false, false, false, false });
     currentCharacters = new List <Character>();
     currentCharacters.AddRange(listOfTeams[currentTeam].GetAliveMembersWithTurnPending());
     currentCharacter = currentCharacters[0];
     BattleUIContainer.RefreshUnitView(currentCharacter);
     GameManager._intance.StartCoroutine(BeginAfterTurnDisplay());
 }
Пример #5
0
 public virtual void Cancel()
 {
     GameManager.SetControlMode(ControlsMode.Disabled);
     TurnManager.currentCharacter.OnPathUpdate   = null;
     TurnManager.currentCharacter.OnPathComplete = null;
     CameraFollow.target    = TurnManager.currentCharacter.body.transform;
     Target.CurrentPosition = TurnManager.currentCharacter.Position;
     TurnManager.currentCharacter.anim.SetBool("move", false);
     RangeDisplayer._Main.Clear();
     RangeDisplayer._Secondary.Clear();
     Target.isOutside = false;
     Target.Clear();
     BattleUIContainer.RefreshUnitView(activator);
     TurnManager.performingAction = false;
 }
Пример #6
0
        public static void Move(GridPosition position, Color color, bool show = true)
        {
            if (indicator == null)
            {
                indicator = UIManager._instance.CreateTargetIndicator(position, color, true);
            }
            indicator.SetTarget(position);
            indicator.SetColor(color);
            indicator.SetShow(show);

            if (Character.GetCharacterAtTile(position) != null)
            {
                BattleUIContainer.RefreshUnitView(Character.GetCharacterAtTile(position));
            }

            currentPosition = position;
        }
Пример #7
0
 public override void Cancel()
 {
     Target.Indicator.SetShow(false);
     BattleUIContainer.RefreshUnitView(activator);
     lastAction.Resume();
 }
Пример #8
0
        public override void Update(GridPosition pos)
        {
            base.Update(pos);
            if (secondary != null)
            {
                return;
            }

            RangeDisplayControls();

            if (pos.Equals(Target.CurrentPosition))
            {
                return;
            }

            int selecteddir = InputHandlerer.GetDirectionFromInput();

            if (pathDraw.GetPath().Count == 0)
            {
                activator.SetAnimatorDirection(selecteddir);
            }



            //Disable walking throught enemy
            if (pathDraw.GetPath().Count > 0)
            {
                if (Character.isOtherCharacterInTile(pathDraw.Last.Clone(), activator))
                {
                    if (pathDraw.GetPath().Count > 1)
                    {
                        if (!pathDraw.LastNode.Previous.Value.Equals(pos))
                        {
                            GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode));
                            return;
                        }
                    }
                }
            }


            //Are we inside of character movement range
            if (currentMovementRange.Exists(item => item.Equals(pos)))
            {
                //Did we enter the movement range?
                if (!Target.isOutside)
                {
                    Target.Clear();


                    bool characterInTile = Character.isCharacterInTile(pos);

                    if (characterInTile)
                    {
                        Character chara = Character.GetCharacterAtTile(pos);

                        if (chara != activator)
                        {
                            if (chara.TeamNumber != activator.TeamNumber && !activator.TurnActionsPreformed[0])
                            {
                                if (pathDraw.AddPath(pos))
                                {
                                    AudioManager._instance.PlayClip("Click_Standard_03");
                                    Target.Move(pos, Color.red);
                                    BattleUIContainer._instance.UnitView.SetDamagePreview(chara.stats, activator.stats);
                                    pathDraw.SetLastWaypointGraphic(Target.Indicator.gameObject);
                                    LastDirection = selecteddir;
                                }
                            }
                        }
                        else
                        {
                            //Return to same tiel as character
                            pathDraw.Destroy();
                            Target.CurrentPosition = activator.Position;
                        }
                    }
                    else
                    {
                        //No characters in tile

                        if (pathDraw.AddPath(pos))
                        {
                            AudioManager._instance.PlayClip("Click_Standard_03");
                            Target.CurrentPosition = pos.Clone();
                            LastDirection          = selecteddir;
                        }
                        BattleUIContainer.RefreshUnitView(activator);
                        BattleUIContainer._instance.UnitView.HideDamagePreview();
                    }
                }
                else
                {
                    //If we return to walkarea from outside
                }
            }
            else
            {
                if (!Target.isOutside)
                {
                    AudioManager._instance.PlayClip("Click_Standard_03");
                    secondary = new ViewAction(this, currentMovementRange);
                    Target.Move(pos, Color.white);
                    TurnManager._instance.AddCancel(secondary.Cancel);
                }
                //Move outside walkable range
                Target.isOutside = true;
            }
            GameManager._intance.StartCoroutine(GameManager.BlockInput(GameManager.controlsMode));
        }