Exemplo n.º 1
0
    public void AddSmallTokenRPC(int viewID, string hero)
    {
        SmallToken toAdd   = PhotonView.Find(viewID).gameObject.GetComponent <SmallToken>();
        Hero       toAddTo = findHero(hero);

        toAddTo.heroInventory.AddSmallToken2(toAdd);
    }
Exemplo n.º 2
0
    public void Execute()
    {
        foreach (Token token in freeMoves)
        {
            if (token is HalfWineskin && token.reserved == 1)
            {
                GameManager.instance.MainHero.heroInventory.RemoveSmallToken((SmallToken)token);
            }
            else if (token is Wineskin && token.reserved == 2)
            {
                GameManager.instance.MainHero.heroInventory.RemoveSmallToken((SmallToken)token);
            }
            else if (token is Wineskin && token.reserved == 1)
            {
                SmallToken halfWineskin = HalfWineskin.Factory();
                GameManager.instance.MainHero.heroInventory.ReplaceSmallToken((SmallToken)token, halfWineskin, true);
            }
            else if (token is Herb && token.reserved != 0)
            {
                GameManager.instance.MainHero.heroInventory.RemoveSmallToken((SmallToken)token);
            }
        }

        freeMoves = new List <Token>();

        if (!PhotonNetwork.OfflineMode)
        {
            photonView.RPC("ExecuteRPC", RpcTarget.AllViaServer, new object[] { totalFreeMoves });
        }
        else
        {
            ExecuteRPC(totalFreeMoves);
        }
    }
Exemplo n.º 3
0
    public void ReplaceSmallToken2(int originalViewID, int newViewID, bool destroy)
    {
        if (smallTokens.Contains(convertToKey(originalViewID)))
        {
            SmallToken token = (SmallToken)PhotonView.Find(newViewID).GetComponent <Token>();
            string     id    = convertToKey(newViewID);

            AllTokens.Remove(convertToKey(originalViewID));
            smallTokens.Remove(convertToKey(originalViewID));

            smallTokens.Add(id, token);
            AllTokens.Add(id, token);

            if (destroy)
            {
                Token tkn = PhotonView.Find(originalViewID).GetComponent <Token>();
                if (tkn != null)
                {
                    GameObject.Destroy(tkn.gameObject);
                }
            }
        }

        if (GameManager.instance.MainHero.TokenName.Equals(parentHero))
        {
            EventManager.TriggerInventoryUIHeroUpdate(this);
        }
        else if (parentHero.Equals(CharChoice.choice.TokenName))
        {
            EventManager.TriggerInventoryUIHeroPeak(this);
        }
    }
Exemplo n.º 4
0
 public void RemoveSmallToken(SmallToken smallToken)
 {
     if (smallTokens.Contains(convertToKey(smallToken.GetComponent <PhotonView>().ViewID)))
     {
         int viewID = smallToken.GetComponent <PhotonView>().ViewID;
         GameManager.instance.photonView.RPC("RemoveSmallTokenRPC", RpcTarget.AllViaServer, new object[] { viewID, parentHero });
     }
     else
     {
         Debug.Log("Error hero inventory remove smallToken");
     }
 }
Exemplo n.º 5
0
 public override void ApplyEffect()
 {
     if (PhotonNetwork.IsMasterClient)
     {
         foreach (Hero hero in GameManager.instance.heroes)
         {
             if (cellsID.Contains(hero.Cell.Index))
             {
                 SmallToken wineskin = Wineskin.Factory();
                 hero.heroInventory.AddSmallToken(wineskin);
             }
         }
     }
 }
Exemplo n.º 6
0
    public void ReplaceSmallToken(SmallToken original, SmallToken newItem, bool destroy = false)
    {
        int originalViewID = original.GetComponent <PhotonView>().ViewID;
        int newViewID      = newItem.GetComponent <PhotonView>().ViewID;

        if (smallTokens.Contains(convertToKey(originalViewID)))
        {
            GameManager.instance.photonView.RPC("ReplaceSmallTokenRPC", RpcTarget.AllViaServer, new object[] { originalViewID, newViewID, destroy, parentHero });
        }
        else
        {
            Debug.Log("Error hero inventory remove BigToken");
        }
    }
Exemplo n.º 7
0
 //what to do with errors
 public bool AddSmallToken(SmallToken smallToken)
 {
     if (smallTokens.Count >= spaceSmall)
     {
         EventManager.TriggerError(1);
         return(false);
     }
     else
     {
         int viewID = smallToken.GetComponent <PhotonView>().ViewID;
         GameManager.instance.photonView.RPC("AddSmallTokenRPC", RpcTarget.AllViaServer, new object[] { viewID, parentHero });
         return(true);
     }
 }
Exemplo n.º 8
0
    public void AddSmallToken2(SmallToken smallToken)
    {
        string id = convertToKey(smallToken.GetComponent <PhotonView>().ViewID);

        smallTokens.Add(id, (SmallToken)smallToken);
        AllTokens.Add(id, (SmallToken)smallToken);

        if (GameManager.instance.MainHero.TokenName.Equals(parentHero))
        {
            EventManager.TriggerInventoryUIHeroUpdate(this);
        }
        else if (parentHero.Equals(CharChoice.choice.TokenName))
        {
            EventManager.TriggerInventoryUIHeroPeak(this);
        }
    }
Exemplo n.º 9
0
    void DistributeWineskins(int warriorWineskins, int archerWineskins, int dwarfWineskins, int mageWineskins)
    {
        GameObject distributeWineskinsGO = GameObject.Find("DistributeWineskins");

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

        if (warriorWineskins > 0 && warrior != null)
        {
            while (warriorWineskins != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Warrior"))
                {
                    SmallToken wineskin = Wineskin.Factory("Warrior");
                }
                warriorWineskins--;
            }
        }

        Hero archer = heroes.Where(x => x.Type.ToString() == "Archer").FirstOrDefault();

        if (archerWineskins > 0 && archer != null)
        {
            while (archerWineskins != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Archer"))
                {
                    SmallToken wineskin = Wineskin.Factory("Archer");
                }
                archerWineskins--;
            }
        }

        Hero dwarf = heroes.Where(x => x.Type.ToString() == "Dwarf").FirstOrDefault();

        if (dwarfWineskins > 0 && dwarf != null)
        {
            while (dwarfWineskins != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Dwarf"))
                {
                    SmallToken wineskin = Wineskin.Factory("Dwarf");
                }
                dwarfWineskins--;
            }
        }

        Hero mage = heroes.Where(x => x.Type.ToString() == "Mage").FirstOrDefault();

        if (mageWineskins > 0 && mage != null)
        {
            while (mageWineskins != 0)
            {
                if (GameManager.instance.MainHero.TokenName.Equals("Mage"))
                {
                    SmallToken wineskin = Wineskin.Factory("Mage");
                }
                mageWineskins--;
            }
        }

        if (PhotonNetwork.IsMasterClient)
        {
            distributeWineskinsGO.SetActive(false);
        }
    }