Esempio n. 1
0
    private static IEnumerator MoveToCannon()
    {
        if (!currentCannon.C.Moved)
        {
            HighlightMaster.HighlightUnitToggle(false, currentCannon.C);
        }

        yield return(TopDownCamera.LerpToPosition(currentCannon.CameraPos[0].transform.position, currentCannon.CameraPos[0].transform.rotation));

        currentCannon.CannonCam.GetComponent <Camera>().enabled = true;
        TopDownCamera.Instance.GetComponent <Camera>().enabled  = false;

        UIMaster.FadePhanel((int)UIPannels.Cannon);
        // UIMaster.TogglePanelLock(false, (int)UIPannels.Action);
        UIMaster.FadePhanel((int)UIPannels.Action);
    }
Esempio n. 2
0
    public static void ExitCannon()
    {
        if (currentCannon != null)
        {
            currentCannon.StartCoroutine(LeaveCannon());
            currentCannon.Selected = false;
            currentCannon.DestroyIndicator();
            currentCannon.ReturnToDefault();

            if (!currentCannon.C.Moved)
            {
                HighlightMaster.HighlightUnitToggle(true, currentCannon.C);
            }

            currentCannon = null;

            soundM.ButtonPress();
        }
    }
Esempio n. 3
0
    public static void BuildCombatAreas()
    {
        if (instance.combatPoints.Count == 0)
        {
            return;
        }

        while (instance.combatPoints.Count != 0)
        {
            Unit origin = instance.combatPoints[0].Unit;
            instance.combatPoints.RemoveAt(0);

            List <Unit> combatArea = BuildCombatArea(origin);
            instance.combatAreas.Add(combatArea);
            foreach (Unit u in combatArea)
            {
                HighlightMaster.HighlightUnitToggle(true, u);
            }
        }
        instance.combatCount = instance.combatAreas.Count;
    }
Esempio n. 4
0
    private static void MoveToTile(HexCell h, ref Unit u)
    {
        HighlightMaster.ToggleTileHighlights(false, MapMaster.CellsWithinArea(u.CurrentHex, u.MoveSpeed));

        MapMaster.Map[u.CurrentHex.R, u.CurrentHex.Q].Passable = true;
        MapMaster.Map[u.CurrentHex.R, u.CurrentHex.Q].Unit     = null;

        u.gameObject.transform.position = h.SpawnVector;

        MapMaster.Map[h.R, h.Q].Unit     = u;
        MapMaster.Map[h.R, h.Q].Passable = false;
        u.Moved = true;

        u.CurrentHex = MapMaster.Map[h.R, h.Q];

        HighlightMaster.HighlightUnitToggle(false, u);

        AttackMaster.BuildCombatPoints(u.CurrentHex);

        u = null;

        UnitsToMove--;
    }
Esempio n. 5
0
    private static IEnumerator FollowPath(List <HexCell> path, Unit u)
    {
        u.Moved = true;
        u.CurrentHex.Passable         = true;
        u.CurrentHex.unit             = null;
        path[path.Count - 1].passable = false;

        Animator a        = null;
        bool     infOrCav = u.UName == "Cannon" ? false : true;

        if (infOrCav)
        {
            a = u.gameObject.GetComponentInChildren <Animator>();
        }

        yield return(new WaitForFixedUpdate());

        ++movingUnits;

        UIMaster.SetActionPanel(false);
        //  path[path.Count - 1].Unit = u;

        if (infOrCav)
        {
            a.Play("MoveStart");
        }

        Rigidbody r = u.gameObject.GetComponent <Rigidbody>();

        if (r != null)
        {
            r.detectCollisions = false;
            r.useGravity       = false;
        }

        yield return(new WaitForSeconds(0.25f));

        SoundMaster.StartUnitMove();

        while (path.Count > 0)
        {
            yield return(new WaitForEndOfFrame());

            yield return(LearpToTile(u, path[0]));

            path.RemoveAt(0);
        }

        SoundMaster.StopUnitMove();

        yield return(new WaitForFixedUpdate());

        --movingUnits;

        if (!(movingUnits > 0))
        {
            UIMaster.SetActionPanel(true);
        }

        if (r != null)
        {
            r.detectCollisions = true;
            r.useGravity       = true;
        }

        if (infOrCav)
        {
            a.Play("MoveEnd");
        }

        u.CurrentHex.Unit    = u;
        u.transform.rotation = u.URotation();
        HighlightMaster.HighlightUnitToggle(false, u);
        AttackMaster.BuildCombatPoints(u.CurrentHex);
    }
Esempio n. 6
0
    public static List <Unit> FightResults()
    {
        List <Unit> toKill = new List <Unit>();
        int         p1     = 0;
        int         p2     = 0;

        if (instance.combatAreas.Count != 0)
        {
            foreach (Unit u in instance.combatAreas[0])
            {
                if (u.Player == 0)
                {
                    p1++;
                }
                else
                {
                    p2++;
                }
                HighlightMaster.HighlightUnitToggle(true, u);
            }
        }

        if (p1 == p2)
        {
            foreach (Unit u in instance.combatAreas[0])
            {
                if (u != null)
                {
                    toKill.Add(u);
                }
            }
        }
        else
        {
            if (p1 > p2)
            {
                p1 = p2;
            }

            else
            {
                p2 = p1;
            }

            foreach (Unit u in instance.combatAreas[0])
            {
                if (u != null)
                {
                    if (u.Player == 0 && p1 != 0)
                    {
                        toKill.Add(u);
                        p1--;
                    }

                    else if (u.Player == 1 && p2 != 0)
                    {
                        toKill.Add(u);
                        p2--;
                    }
                }
            }
        }

        foreach (Unit u in instance.combatAreas[0])
        {
            if (u != null)
            {
                HighlightMaster.HighlightUnitToggle(false, u);
            }
        }

        instance.combatAreas.Remove(instance.combatAreas[0]);
        instance.combatCount--;
        return(toKill);
    }
Esempio n. 7
0
    public static void ResolveFight()
    {
        int p1 = 0;
        int p2 = 0;

        if (instance.combatAreas.Count != 0)
        {
            foreach (Unit u in instance.combatAreas[0])
            {
                if (u.Player == 0)
                {
                    p1++;
                }
                else
                {
                    p2++;
                }
                HighlightMaster.HighlightUnitToggle(true, u);
            }
        }

        if (p1 == p2)
        {
            foreach (Unit u in instance.combatAreas[0])
            {
                if (u != null)
                {
                    PlayerMaster.KillUnit(u);
                }
            }
        }
        else
        {
            if (p1 > p2)
            {
                p1 = p2;
            }

            else
            {
                p2 = p1;
            }

            foreach (Unit u in instance.combatAreas[0])
            {
                if (u != null)
                {
                    if (u.Player == 0 && p1 != 0)
                    {
                        PlayerMaster.KillUnit(u);
                        p1--;
                    }

                    else if (u.Player == 1 && p2 != 0)
                    {
                        PlayerMaster.KillUnit(u);
                        p2--;
                    }
                }
            }
        }

        foreach (Unit u in instance.combatAreas[0])
        {
            if (u != null)
            {
                HighlightMaster.HighlightUnitToggle(false, u);
            }
        }

        instance.combatAreas.Remove(instance.combatAreas[0]);
        instance.combatCount--;
    }