Beispiel #1
0
    public static GoldCoin Factory(string hero)
    {
        GoldCoin goldCoin = GoldCoin.Factory();

        GameManager.instance.findHero(hero).heroInventory.AddItem(goldCoin);
        return(goldCoin);
    }
    public void DropItem()
    {
        if (token is SmallToken)
        {
            GameManager.instance.MainHero.heroInventory.RemoveSmallToken((SmallToken)this.token);
            Cell cell = GameManager.instance.MainHero.Cell;
            cell.Inventory.AddToken(this.token);
        }
        else if (token is BigToken)
        {
            GameManager.instance.MainHero.heroInventory.RemoveBigToken((BigToken)this.token);
            Cell cell = GameManager.instance.MainHero.Cell;
            cell.Inventory.AddToken(this.token);
        }
        else if (token is Helm)
        {
            GameManager.instance.MainHero.heroInventory.RemoveHelm((Helm)this.token);
            Cell cell = GameManager.instance.MainHero.Cell;
            cell.Inventory.AddToken(this.token);
        }
        else if (token is GoldCoin)
        {
            GameManager.instance.MainHero.heroInventory.RemoveGold(1);
            Cell  cell     = GameManager.instance.MainHero.Cell;
            Token goldCoin = GoldCoin.Factory();
            cell.Inventory.AddToken(goldCoin);
        }

        HideHeroActions();
    }
Beispiel #3
0
    public static GoldCoin Factory(int cellID)
    {
        GoldCoin goldCoin = GoldCoin.Factory();

        goldCoin.Cell = Cell.FromId(cellID);
        return(goldCoin);
    }
Beispiel #4
0
 public override void ApplyEffect()
 {
     if (GameManager.instance.CurrentPlayer != GameManager.instance.MainHero)
     {
         return;
     }
     GoldCoin.Factory(Cell.Index);
 }
 void Finalize()
 {
     while (archerGold != 0)
     {
         GoldCoin.Factory("Archer");
         archerGold--;
     }
     while (dwarfGold != 0)
     {
         GoldCoin.Factory("Dwarf");
         dwarfGold--;
     }
     while (mageGold != 0)
     {
         GoldCoin.Factory("Mage");
         mageGold--;
     }
     while (warriorGold != 0)
     {
         GoldCoin.Factory("Warrior");
         warriorGold--;
     }
     while (archerWP != 0)
     {
         Hero a = GameManager.instance.findHero("Archer");
         a.setWP(a.Willpower + 1);
         archerWP--;
     }
     while (dwarfWP != 0)
     {
         Hero a = GameManager.instance.findHero("Dwarf");
         a.setWP(a.Willpower + 1);
         dwarfWP--;
     }
     while (mageWP != 0)
     {
         Hero a = GameManager.instance.findHero("Mage");
         a.setWP(a.Willpower + 1);
         mageWP--;
     }
     while (warriorWP != 0)
     {
         Hero a = GameManager.instance.findHero("Warrior");
         a.setWP(a.Willpower + 1);
         warriorWP--;
     }
 }
Beispiel #6
0
    void DistributeGold(int warriorGold, int archerGold, int dwarfGold, int mageGold)
    {
        GameObject distributeGoldGO = GameObject.Find("DistributeGold");

        Hero warrior = heroes.Where(x => x.Type.ToString() == "Warrior").FirstOrDefault();

        if (warriorGold > 0 && warrior != null)
        {
            while (warriorGold != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Warrior"))
                {
                    Token goldCoin = GoldCoin.Factory("Warrior");
                }
                warriorGold--;
            }
        }
        Hero archer = heroes.Where(x => x.Type.ToString() == "Archer").FirstOrDefault();

        if (archerGold > 0 && archer != null)
        {
            while (archerGold != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Archer"))
                {
                    Token goldCoin = GoldCoin.Factory("Archer");
                }
                archerGold--;
            }
        }
        Hero dwarf = heroes.Where(x => x.Type.ToString() == "Dwarf").FirstOrDefault();

        if (dwarfGold > 0 && dwarf != null)
        {
            while (dwarfGold != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Dwarf"))
                {
                    Token goldCoin = GoldCoin.Factory("Dwarf");
                }
                dwarfGold--;
            }
        }
        Hero mage = heroes.Where(x => x.Type.ToString() == "Mage").FirstOrDefault();

        if (mageGold > 0 && mage != null)
        {
            while (mageGold != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Mage"))
                {
                    Token goldCoin = GoldCoin.Factory("Mage");
                }
                mageGold--;
            }
        }

        if (PhotonNetwork.IsMasterClient)
        {
            distributeGoldGO.SetActive(false);
        }
    }
Beispiel #7
0
    void LoadGame(string directory)
    {
        // Load from json here
        // Heroes
        foreach (Hero hero in heroes)
        {
            hero.Load(directory);
        }

        // Cells
        CellStates Cells = FileManager.Load <CellStates>(directory + "/Cells.json");

        foreach (CellState cellstate in Cells.cellStates)
        {
            foreach (string token in cellstate.inventory)
            {
                Type type = Type.GetType(token);
                if (type == typeof(Farmer))
                {
                    farmers.Add(Farmer.Factory(cellstate.index));
                }
                else if (type == typeof(Gor))
                {
                    gors.Add(Gor.Factory(cellstate.index));
                }
                else if (type == typeof(Skral))
                {
                    skrals.Add(Skral.Factory(cellstate.index));
                }
                else if (type == typeof(Wardrak))
                {
                    wardraks.Add(Wardrak.Factory(cellstate.index));
                }
                else if (type == typeof(TowerSkral))
                {
                    towerskrals.Add(TowerSkral.Factory(cellstate.index, players.Count));
                }
                else if (type.IsSubclassOf(typeof(Fog)))
                {
                    string id = type.ToString().Replace("Fog", "");
                    Fog.Load(id, type, cellstate.index);
                }
                else if (type == typeof(Well))
                {
                    wells.Add(Well.Factory(cellstate.index));
                }
                // Items in cells
                if (PhotonNetwork.IsMasterClient)
                {
                    if (type == typeof(GoldCoin))
                    {
                        GoldCoin.Factory(cellstate.index);
                    }
                    else if (type.IsSubclassOf(typeof(SmallToken)))
                    {
                        type.GetMethod("Factory", new[] { typeof(int) }).Invoke(type, new object[] { cellstate.index });
                    }
                    else if (type.IsSubclassOf(typeof(BigToken)))
                    {
                        type.GetMethod("Factory", new[] { typeof(int) }).Invoke(type, new object[] { cellstate.index });
                    }
                }
            }
        }

        // Narrator
        NarratorState narratorState = FileManager.Load <NarratorState>(directory + "/Narrator.json");

        narrator.Load(narratorState);

        // Wells
        WellsState wellsState = FileManager.Load <WellsState>(directory + "/Wells.json");

        foreach (int cellId in wellsState.wellsCellId)
        {
            bool found = false;
            foreach (Well well in wells)
            {
                if (well.Cell.Index == cellId)
                {
                    found = true;
                    break;
                }
            }

            // If not found, the well is empty
            if (!found)
            {
                wells.Add(Well.Factory(cellId, false));
            }
        }
    }