IsLocalTeam() public méthode

public IsLocalTeam ( int teamID ) : bool
teamID int
Résultat bool
Exemple #1
0
    public void OnGUI()
    {
        Scheduler s = GetComponent <Scheduler>();
        Arbiter   a = GetComponent <Arbiter>();

        if (pendingTargetedSkill != null)
        {
            if (targetingChoices == null || targetingChoices.Length == 0)
            {
                targetingChoices = new string[] {
                    "Tile",
                    "Character",
                    "Cancel"
                };
            }
            int choice = OnGUIChoices("Target tile or character?", targetingChoices);
            if (choice != -1)
            {
                if (choice == 0)
                {
                    pendingTargetedSkill.ConfirmDelayedSkillTarget(TargetOption.Path);
                }
                else if (choice == 1)
                {
                    pendingTargetedSkill.ConfirmDelayedSkillTarget(TargetOption.Character);
                }
                else if (choice == 2)
                {
                    pendingTargetedSkill.IncrementalCancel();
                }
                pendingTargetedSkill = null;
            }
            return;
        }
        bool      showAnySchedulerButtons = true;
        bool      showCancelButton        = true;
        Character ac     = s.activeCharacter;
        var       skills = ac == null ? new SkillDef[0] : ac.Skills;

        if (ac != null)
        {
            if (map == null)
            {
                map = transform.parent.GetComponent <Map>();
            }
            MoveSkillDef ms = ac.moveSkill;
            if (ms != null && ms.isActive)
            {
                if (a.IsLocalTeam(ac.EffectiveTeamID))
                {
                    MoveExecutor me = ms.Executor;
                    if (!me.IsMoving)
                    {
                        if (ms.RequireConfirmation &&
                            ms.AwaitingConfirmation)
                        {
                            bool yesButton = false, noButton = false;
                            OnGUIConfirmation("Move here?", out yesButton, out noButton);
                            if (yesButton)
                            {
                                ms.ApplyCurrentTarget();
                                ms.AwaitingConfirmation = false;
                            }
                            if (noButton)
                            {
                                ms.AwaitingConfirmation = false;
                                ms.TemporaryMove(map.InverseTransformPointWorld(me.position));
                            }
                            showCancelButton = false;
                        }
                        else
                        {
                            showCancelButton = false;
                        }
                        showAnySchedulerButtons = false;
                    }
                    else
                    {
                        showAnySchedulerButtons = false;
                        showCancelButton        = false;
                    }
                }
            }

            foreach (SkillDef skill in skills)
            {
                if (!skill.isPassive && skill.isActive && skill is ActionSkillDef && !(skill is MoveSkillDef || skill is WaitSkillDef))
                {
                    ActionSkillDef ask = skill as ActionSkillDef;
                    if (a.IsLocalTeam(ac.EffectiveTeamID))
                    {
                        if (ask.RequireConfirmation &&
                            ask.AwaitingConfirmation)
                        {
                            bool yesButton = false, noButton = false;
                            OnGUIConfirmation("Confirm?", out yesButton, out noButton);
                            if (yesButton)
                            {
                                ask.ApplyCurrentTarget();
                            }
                            if (noButton)
                            {
                                ask.AwaitingConfirmation = false;
                            }
                        }
                        showAnySchedulerButtons = false;
                    }
                }
            }
            WaitSkillDef ws = ac.waitSkill;
            if (ws != null && ws.isActive)
            {
                if (a.IsLocalTeam(ac.EffectiveTeamID))
                {
                    if (ws.RequireConfirmation &&
                        ws.AwaitingConfirmation)
                    {
                        bool yesButton = false, noButton = false;
                        OnGUIConfirmation("Wait here?", out yesButton, out noButton);
                        if (yesButton)
                        {
                            ws.ApplyCurrentTarget();
                        }
                        if (noButton)
                        {
                            ws.AwaitingConfirmation = false;
                        }
                    }
                    else
                    {
                        showCancelButton = permitMultipleMoves || permitMultipleActions || !(activeCharacterHasMoved && activeCharacterHasActed);
                    }
                    showAnySchedulerButtons = false;
                }
            }
        }
        if (s is CTScheduler)
        {
            if (ac != null && a.IsLocalTeam(ac.EffectiveTeamID))
            {
                GUILayout.BeginArea(new Rect(
                                        8, 8,
                                        128, 240
                                        ));
                GUILayout.Label("Character:" + ac.gameObject.name);
                GUILayout.Label("HP: " + Mathf.Ceil(ac.GetStat("health", ac.GetStat("HP"))));
                GUILayout.Label("CT: " + Mathf.Floor(ac.GetStat((s as CTScheduler).ctStat)));

                //TODO:0: support skills
                //show list of skills
                SkillDef activeSkill = null;
                foreach (SkillDef sk in skills)
                {
                    if (sk.isActive)
                    {
                        activeSkill = sk;
                        break;
                    }
                }
                if (activeSkill == null)
                {
                    //root: move, act group, wait
                    var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                    selectedGroup = nextSel == null ? null : nextSel.ToList();
                }
                else if (showCancelButton)
                {
                    if (GUILayout.Button("Cancel " + activeSkill.skillName))
                    {
                        activeSkill.Cancel();
                    }
                }
                GUILayout.EndArea();
            }
        }
        else if (s is TeamRoundsPickAnyOnceScheduler)
        {
            TeamRoundsPickAnyOnceScheduler tps = s as TeamRoundsPickAnyOnceScheduler;
            GUILayout.BeginArea(new Rect(
                                    8, 8,
                                    110, 240
                                    ));
            GUILayout.Label("Current Team:" + tps.currentTeam);
            if (ac != null)
            {
                GUILayout.Label("Character:" + ac.gameObject.name);
                GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health")));
                //show list of skills
                SkillDef activeSkill = null;
                foreach (SkillDef sk in skills)
                {
                    if (sk.isActive)
                    {
                        activeSkill = sk;
                        break;
                    }
                }
                if (activeSkill == null)
                {
                    //root: move, act group, wait
                    var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                    selectedGroup = nextSel == null ? null : nextSel.ToList();
                }
                else if (showCancelButton)
                {
                    if (GUILayout.Button("Cancel " + activeSkill.skillName))
                    {
                        activeSkill.Cancel();
                    }
                }
            }
            else
            {
                GUILayout.Label("Click any team member");
            }
            if (a.IsLocalTeam(tps.currentTeam))
            {
                if (showAnySchedulerButtons &&
                    !(ac != null && ac.moveSkill.Executor.IsMoving) &&
                    GUILayout.Button("End Round"))
                {
                    tps.EndRound();
                }
            }
            GUILayout.EndArea();
        }
        else if (s is TeamRoundsPointsScheduler)
        {
            TeamRoundsPointsScheduler tps = s as TeamRoundsPointsScheduler;
            if (a.IsLocalTeam(tps.currentTeam))
            {
                GUILayout.BeginArea(new Rect(
                                        8, 8,
                                        110, 240
                                        ));
                GUILayout.Label("Current Team: " + tps.currentTeam);
                GUILayout.Label("Points Left: " + tps.pointsRemaining);
                if (ac != null)
                {
                    GUILayout.Label("Character:" + ac.gameObject.name);
                    GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health")));
                    RoundPointsCharacter rpc = ac.GetComponent <RoundPointsCharacter>();
                    GUILayout.Label("AP: " + Mathf.Floor(rpc.Limiter));

                    //show list of skills
                    SkillDef activeSkill = null;
                    foreach (SkillDef sk in skills)
                    {
                        if (sk.isActive)
                        {
                            activeSkill = sk;
                            break;
                        }
                    }
                    if (activeSkill == null)
                    {
                        //root: move, act group, wait
                        var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                        selectedGroup = nextSel == null ? null : nextSel.ToList();
                    }
                    else if (showCancelButton)
                    {
                        if (GUILayout.Button("Cancel " + activeSkill.skillName))
                        {
                            activeSkill.Cancel();
                        }
                        if (showAnySchedulerButtons &&
                            activeSkill is MoveSkillDef &&
                            !(activeSkill as MoveSkillDef).Executor.IsMoving)
                        {
                            if (GUILayout.Button("End Move"))
                            {
                                //??
                                activeSkill.ApplySkill();
                            }
                        }
                    }
                }
                else
                {
                    if (showAnySchedulerButtons &&
                        !(ac != null && ac.moveSkill.Executor.IsMoving) &&
                        GUILayout.Button("End Round"))
                    {
                        tps.EndRound();
                    }
                }
                GUILayout.EndArea();
            }
        }
        else if (s is TeamRoundsInitiativeScheduler || s is RoundsInitiativeScheduler)
        {
            GUILayout.BeginArea(new Rect(
                                    8, 8,
                                    110, 240
                                    ));
            TeamRoundsInitiativeScheduler tis = s as TeamRoundsInitiativeScheduler;
            if (tis != null)
            {
                GUILayout.Label("Current Team:" + tis.currentTeam);
            }
            if (ac != null)
            {
                GUILayout.Label("Character:" + ac.gameObject.name);
                GUILayout.Label("Health: " + Mathf.Ceil(ac.GetStat("health")));
                //show list of skills
                SkillDef activeSkill = null;
                foreach (SkillDef sk in skills)
                {
                    if (sk.isActive)
                    {
                        activeSkill = sk;
                        break;
                    }
                }
                if (activeSkill == null)
                {
                    //root: move, act group, wait
                    var nextSel = OnGUISkillGroup(ac, skills, selectedGroup);
                    selectedGroup = nextSel == null ? null : nextSel.ToList();
                }
                else if (showCancelButton)
                {
                    if (GUILayout.Button("Cancel " + activeSkill.skillName))
                    {
                        activeSkill.Cancel();
                    }
                }
            }
            GUILayout.EndArea();
        }
    }