public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
		if (stream.isWriting)
		{
			stream.SendNext (new Serializer().SerializeToString(ability));
			stream.SendNext (ready);
			//stream.SendNext (active);
		}
		else
		{
			//cost = (int)stream.ReceiveNext ();
			ability = new Serializer().DeserializeFromString<ChampAbility>((string)stream.ReceiveNext ());

			ready = (bool)stream.ReceiveNext ();
		}
	}
Example #2
0
    public ChampAbility getChampAbility(string id)
    {
        if (id == "abiTest")
        {
            abi = new TestAbility();
        }

        if (id == "aY0")
        {
            abi = new abiHeal();
        }

        if (id == "aR0")
        {
            abi = new abiReinforce();
        }

        if (id == "aU0")
        {
            abi = new abiScry();
        }

        if (id == "aG0")
        {
            abi = new abiSummonPlant();
        }

        if (id == "aP0")
        {
            abi = new abiLifeDrain();
        }

        if (id == "aW0")
        {
            abi = new abiFort();
        }

        abi.id = id;
        return(abi);
    }
	// Update is called once per frame
	void Update () {

		if (PhotonNetwork.isMasterClient) {
			ability = ownerChamp.abilites [num];
			ability.champTag = ownerChamp.tag;
		
			//render ();
			a=0;
			totalReq=0;
			for (int i = 0; i < 6; i++) {
				if(ability.reqPower [i]>0) {

					totalReq += 1;
				}
			
			}
			for (int i = 0; i < 6; i++) {
		
				if (ownerChamp.power [i] >= ability.reqPower [i] && ability.reqPower [i]!=0) {
			

					a += 1;
				}
		
			}

			if (a != totalReq) {
				ready = false;
				//mr.material.color = new Color (0.5f, 0.5f, 0.5f, 1);
			} else {
		
				ready = true;
				//mr.material.color = new Color (1.0f, 1.0f, 1.0f, 1);
			}
		}

		if (ready) {
			mr.material.color = new Color (1.0f, 1.0f, 1.0f, 1);
		} else {
			mr.material.color = new Color (0.5f, 0.5f, 0.5f, 1);
		}

		if (ability.image != "") {

			if (ready || ownerChamp.playerName == PhotonNetwork.player.NickName) {
				text.text = ""+ability.cost;
				if (ability.active) {
				
					Sprite spArt = Resources.Load ("Sprites/Abilities/" + ability.image, typeof(Sprite)) as Sprite;
					mr.material.mainTexture = spArt.texture;
					//Debug.Log ("aact");
				} else {
					Sprite spArt = Resources.Load ("Sprites/Abilities/blankSymbol", typeof(Sprite)) as Sprite;
					mr.material.mainTexture = spArt.texture;
					//Debug.Log ("blank");
				}
			} else {
				text.text = "?";
				Sprite spArt = Resources.Load ("Sprites/Abilities/blankSymbol", typeof(Sprite)) as Sprite;
				mr.material.mainTexture = spArt.texture;
			}


		
		}
		

	}
    public ChampAbility loadAbility(string id)
    {
        ChampAbility ability = new ChampAbility();


        ability = new AbiFactory().getChampAbility(id);


        TextAsset path = Resources.Load("xml/AbilityData", typeof(TextAsset)) as TextAsset;
        //			Debug.Log (path);

        //Debug.Log ("not null");
        XElement root             = XElement.Parse(path.text);
        IEnumerable <XElement> cd =
            from el in root.Elements("abilites").Elements("ability")
            where el.Attribute("id").Value == id
            select el;

        XElement abiData = cd.First();

        ability.cost  = int.Parse(abiData.Element("cost").Value);
        ability.type  = abiData.Element("type").Value;
        ability.image = abiData.Element("image").Value;

        ability.cData = loadAbiCardData(id);
        //ability.reqPower

        string reqPool = abiData.Element("req").Value;

        if (abiData.Element("req").Value != "")
        {
            List <string> reqPoolList = reqPool.Split(' ').ToList <string> ();

            foreach (var power in reqPoolList)
            {
                if (power == "r")
                {
                    ability.reqPower[0] += 1;
                }

                if (power == "u")
                {
                    ability.reqPower[1] += 1;
                }

                if (power == "y")
                {
                    ability.reqPower[2] += 1;
                }

                if (power == "p")
                {
                    ability.reqPower[3] += 1;
                }
                if (power == "g")
                {
                    ability.reqPower[4] += 1;
                }
                if (power == "w")
                {
                    ability.reqPower[5] += 1;
                }
            }
        }

        return(ability);
    }