public float CalculateDamage(int power, int attackCategory, Lifie defenderLifie) { float Damage; float s; float d; float modifier = 1; if (attackCategory == 1) { s = GetMagic(); d = defenderLifie.GetMagicDefense(); } else if (attackCategory == 2) { s = GetStrength(); d = defenderLifie.GetDefense(); } else { s = 1; d = 1; } //Damage = ((2 * Level / 5 + 2) * power * (s / d) / 50 + 2) * modifier; Damage = (7 + Level / 200 * power * s / d) * modifier; return(Damage); }
private void ReadCurrentLifies() { Lifies = new List <GameObject>(); foreach (GameObject Lifie in GameObject.FindGameObjectsWithTag("Lifie")) { Lifies.Add(Lifie); Debug.Log("added: " + Lifie.GetComponent <Lifie>().Name); } }
public void Reset() { SelectingTarget = false; SelectedLifie = null; SelectedAttack = null; CancelActionBackup = new Vector3(); GameObject.Find("MetaObject").GetComponent <MetaObject>().ResetTiles(); HideActionUI(); HideAttackUI(); }
private void SelectLifie() { if (!HoveringLifie) { return; } if (!HoveringLifie.CanWalk) { return; } SelectedLifie = HoveringLifie; CancelActionBackup = new Vector3(SelectedLifie.transform.position.x, SelectedLifie.transform.position.y, SelectedLifie.transform.position.z); GameObject.Find("LogBox").GetComponent <LogBox>().SetLogBoxText("Selected " + SelectedLifie.Name + "."); }
public void ReadLifieLists() { Player1Lifies.Clear(); Player2Lifies.Clear(); ReadCurrentLifies(); foreach (GameObject Lifie in Lifies) { if (Lifie.GetComponent <LifiePlayer>() != null) { Player1Lifies.Add(Lifie); } else if (Lifie.GetComponent <LifieCPU>() != null) { Player2Lifies.Add(Lifie); } } Debug.Log("Lifie Lists: playable: " + Player1Lifies.Count + "\n opponent lifies: " + Player2Lifies.Count); }
public void nextTurn() { playerTurn = !playerTurn; ReadLifieLists(); List <GameObject> tempList1; List <GameObject> tempList2; if (playerTurn) { tempList1 = Player1Lifies; tempList2 = Player2Lifies; } else { tempList1 = Player2Lifies; tempList2 = Player1Lifies; } foreach (GameObject Lifie in tempList1.ToArray()) { Lifie templifie = Lifie.GetComponent <Lifie>(); templifie.Enable(); templifie.AP += 20; if (templifie.AP > templifie.TotalAP) { templifie.AP = templifie.TotalAP; } } foreach (GameObject Lifie in tempList2.ToArray()) { Lifie.GetComponent <Lifie>().Disable(); } GameObject.Find("LogBox").GetComponent <LogBox>().SetLogBoxText("Next Turn! Select a Lifie."); }
public void CheckForNextTurn() { ReadLifieLists(); List <GameObject> tempList; if (playerTurn) { tempList = Player1Lifies; } else { tempList = Player2Lifies; } foreach (GameObject Lifie in tempList) { if (Lifie.GetComponent <Lifie>().CanWalk) { return; } } nextTurn(); }
public bool Attack(Lifie targetLifie, Attack attack) { if ( ( attack.isStatusAttack() && ( (gameObject.GetComponent <LifiePlayer>() && targetLifie.gameObject.GetComponent <LifieCPU>()) || (gameObject.GetComponent <LifieCPU>() && targetLifie.gameObject.GetComponent <LifiePlayer>()) ) ) || ( !attack.isStatusAttack() && ( (gameObject.GetComponent <LifiePlayer>() && targetLifie.gameObject.GetComponent <LifiePlayer>()) || (gameObject.GetComponent <LifieCPU>() && targetLifie.gameObject.GetComponent <LifieCPU>()) ) ) ) { return(false); } if (AP - attack.APDrain < 0) { GameObject.Find("LogBox").GetComponent <LogBox>().SetLogBoxText("This lifie doesn't have enough AP for this attack!"); return(false); } RaycastHit[] hits; hits = Physics.RaycastAll(targetLifie.transform.position, new Vector3(0, -0.5f, 0)); foreach (RaycastHit hit in hits) { if (hit.collider.gameObject.tag == "Tile") { if (hit.collider.gameObject.GetComponent <Tile>().selectable) { if (!attack.isStatusAttack()) { float multiplier = ElementMultiplier(attack.Element, targetLifie.Element); float damage = CalculateDamage(attack.Power, attack.Category, targetLifie) * multiplier; targetLifie.LP -= damage; AP -= attack.APDrain; string logtext = targetLifie.Name + " took " + (int)Math.Round(damage, MidpointRounding.AwayFromZero) + " damage from " + Name; if (multiplier > 1) { logtext = "Super effective!\n" + logtext + "!"; } else if (multiplier < 1) { logtext = "Not very effective...\n" + logtext + "..."; } else { logtext += "."; } GameObject.Find("LogBox").GetComponent <LogBox>().SetLogBoxText(logtext); } else { string temps = ""; //stats change switch (attack.Category) { case 3: //Strength targetLifie.StrengthModifier += attack.EffectPower; temps = "strength"; break; case 4: //Defense targetLifie.DefenseModifier += attack.EffectPower; temps = "defense"; break; default: Debug.Log("Need to setup Lifie.Attack //stats change case > 5"); break; } GameObject.Find("LogBox").GetComponent <LogBox>().SetLogBoxText(targetLifie.Name + "'s " + temps + " was increased!"); } return(true); } } } return(false); }
void Update() { if (disabled) { return; } if (SelectedLifie) { SetColor(ColorSelected); } else if (HoveringLifie) { SetColor(ColorHover); } else { SetColor(ColorStandard); } if (!isActionUIOpen && !isAttackUIOpen) { if (Input.GetKeyDown(KeyCode.LeftArrow)) { Move("Left"); return; } if (Input.GetKeyDown(KeyCode.UpArrow)) { Move("Up"); return; } if (Input.GetKeyDown(KeyCode.RightArrow)) { Move("Right"); return; } if (Input.GetKeyDown(KeyCode.DownArrow)) { Move("Down"); return; } } else { if (Input.GetKeyDown(KeyCode.UpArrow)) { MoveOtherCursor("Up"); return; } if (Input.GetKeyDown(KeyCode.DownArrow)) { MoveOtherCursor("Down"); return; } } if (Input.GetKeyDown(KeyCode.Space)) { Click(); return; } if (Input.GetKeyDown(KeyCode.Escape)) { if (SelectedLifie) { CancelAction(); } Reset(); return; } HoveringLifie = GetHoveringLifie(); HoveringTile = GetHoveringTile(); CheckForInfoUI(); if (isAttackUIOpen) { HoveringAttack = GetHoveringAttack(); } }