// To select monster function public void ConformSelectionBtnClicked() { // reduce the chose times p1.RemainingMonsters -= 1; // synchronize for player two view.RPC("ReduceMonsters", PhotonTargets.Others); // get monster from card TrackableBehaviour tr = GlobalValues.Instance.GetFirstTrackableImage(); ElementiaMonster monster = GlobalValues.Instance.GetMonster(tr); // save the selected monster to attack monster p1.AttackMonster = monster; //synchronize view.RPC("ChangeMonsters", PhotonTargets.Others, monster.Name); // get extra hp from the selected monster p1.HP += monster.HP; p1.StartHp += monster.HP; // synchron view.RPC("ChangePlayerTwoHp", PhotonTargets.Others, p1.HP); view.RPC("ChangeStartHp", PhotonTargets.Others, p1.StartHp); // set player one this round is over FightMenuController.Instance.IsMyTurn = false; // synchron view.RPC("changePlayerRound", PhotonTargets.Others, true); FightMenuController.Instance.RefreshUI(); // hide this conform button gameObject.SetActive(false); }
public void AddMonsterBtnPressed() { // get monster TrackableBehaviour tb; tb = GlobalValues.Instance.GetFirstTrackableImage(); ElementiaMonster monster = GlobalValues.Instance.GetMonster(tb); // add monster for p1 ElementiaPlayer p1 = GameObject.FindGameObjectWithTag("PlayerOne").GetComponent <ElementiaPlayer>(); p1.Monsters.Add(monster); // synchronize p1 selected monster for p2 PhotonView view = GameObject.FindGameObjectWithTag("RemoteController").GetComponent <PhotonView>(); view.RPC("addMonsterForPlayerTwo", PhotonTargets.Others, monster.Name); // Change the above information content, to shwo how many monster did player already seledted ElementiaPlayer p2 = GameObject.FindGameObjectWithTag("PlayerTwo").GetComponent <ElementiaPlayer>(); SelectMenuController.Instance.ChangeInformation(p1, p2); // show or hide add/remove monster btn SelectMenuController.Instance.SetBtnStatus(); }
private void Start() { p1 = GameObject.FindGameObjectWithTag("PlayerOne").GetComponent <ElementiaPlayer>(); p2 = GameObject.FindGameObjectWithTag("PlayerTwo").GetComponent <ElementiaPlayer>(); p1AttackMonster = p1.AttackMonster; p2AttackMonster = p2.AttackMonster; view = GameObject.FindGameObjectWithTag("RemoteController").GetComponent <PhotonView>(); }
/// <summary> /// The main attact function /// </summary> /// <returns>Damage Value</returns> /// <param name="attMonst">Attack Monster</param> /// <param name="defMonst">Defend Monster</param> public static float ElementiaDamageFunction(ElementiaMonster attMonst, ElementiaMonster defMonst) { bool hit = Hit(defMonst.Evasiveness); if (!hit) { return(0f); } System.Random r = new System.Random(); float elm = ElmentialDamageCoeffient(attMonst, defMonst); double critical = 0.65 * r.NextDouble() + 0.95; //Debug.Log("critical= " + critical); return((attMonst.Attact - defMonst.Defense) * elm * (float)critical); }
/// <summary> /// create a floating attack text /// </summary> /// <param name="monster">Monster, where the floating text should appear</param> /// <param name="value">content of the floating text</param> public static void CreateFloatingText(ElementiaMonster monster, string value) { GameObject canvas = GameObject.Find("Canvas"); Transform location = GameObject.FindGameObjectWithTag(monster.Name).transform; // load the text prefab FloatingText popupText = Resources.Load <FloatingText>("Prefabs/PopupTextParent"); // create a new clone of the prefab FloatingText instance = Instantiate(popupText); Vector3 screenPosition = Camera.main.WorldToScreenPoint(location.position); instance.transform.SetParent(canvas.transform, true); instance.transform.position = screenPosition; instance.SetText(value); }
// reduce the player two hp and synchronize this action after attact void getDamage(ElementiaMonster monster, int amount) { if (amount > 0) // if attact not missed { // play hit animation GameObject.FindGameObjectWithTag(monster.Name).GetComponent <Animator>().Play("Hit"); // synchronize for player two view.RPC("playHitAnimation", PhotonTargets.Others, monster.Name); // float attack value FloatingTextController.CreateFloatingText(monster, amount.ToString()); // synchronize attack value for player two view.RPC("floatAttackValue", PhotonTargets.Others, amount.ToString()); } // miss attact if (amount == 0) { // float miss text FloatingTextController.CreateFloatingText(monster, "Miss"); // synchronize miss text for player two view.RPC("floatAttackValue", PhotonTargets.Others, "miss"); } }
void addMonsterForPlayerTwo(string name) { ElementiaMonster monster = GlobalValues.Instance.GetMonster(name); p2.Monsters.Add(monster); }
void ChangeStartMonsters(string name) { ElementiaMonster monster = GlobalValues.Instance.GetMonster(name); p2.Monsters[0] = monster; }
void ChangeMonsters(string name) { ElementiaMonster monster = GlobalValues.Instance.GetMonster(name); p2.AttackMonster = monster; }
/// <summary> /// Get the Elemental Damage Coeffient /// </summary> /// <returns>The damage coeffient in float between 0.5 to 1.5 </returns> /// <param name="attMonst">Monster, who attack</param> /// <param name="defMonst">Monster, who defend</param> static float ElmentialDamageCoeffient(ElementiaMonster attMonst, ElementiaMonster defMonst) { float dmgCoeffient = 0; // Fire attacks if (attMonst.Type == ElementiaMonsterTypes.Fire) { if (defMonst.Type == ElementiaMonsterTypes.Earth) { dmgCoeffient = 1.5f; } else if (defMonst.Type == ElementiaMonsterTypes.Water) { dmgCoeffient = 0.5f; } else if (defMonst.Type == ElementiaMonsterTypes.Air) { dmgCoeffient = 1.0f; } else if (defMonst.Type == ElementiaMonsterTypes.Fire) { dmgCoeffient = 1.0f; } } // Water attacks if (attMonst.Type == ElementiaMonsterTypes.Water) { if (defMonst.Type == ElementiaMonsterTypes.Fire) { dmgCoeffient = 1.5f; } else if (defMonst.Type == ElementiaMonsterTypes.Air) { dmgCoeffient = 0.5f; } else if (defMonst.Type == ElementiaMonsterTypes.Earth) { dmgCoeffient = 1.0f; } else if (defMonst.Type == ElementiaMonsterTypes.Water) { dmgCoeffient = 1.0f; } } // Earth attacks if (attMonst.Type == ElementiaMonsterTypes.Earth) { if (defMonst.Type == ElementiaMonsterTypes.Air) { dmgCoeffient = 1.5f; } else if (defMonst.Type == ElementiaMonsterTypes.Fire) { dmgCoeffient = 0.5f; } else if (defMonst.Type == ElementiaMonsterTypes.Water) { dmgCoeffient = 1.0f; } else if (defMonst.Type == ElementiaMonsterTypes.Earth) { dmgCoeffient = 1.0f; } } // Air attacks if (attMonst.Type == ElementiaMonsterTypes.Air) { if (defMonst.Type == ElementiaMonsterTypes.Water) { dmgCoeffient = 1.3f; } else if (defMonst.Type == ElementiaMonsterTypes.Earth) { dmgCoeffient = 1.4f; } else if (defMonst.Type == ElementiaMonsterTypes.Fire) { dmgCoeffient = 1.0f; } else if (defMonst.Type == ElementiaMonsterTypes.Air) { dmgCoeffient = 1.0f; } } return(dmgCoeffient); }