示例#1
0
    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);
    }
示例#2
0
 private void ReadCurrentLifies()
 {
     Lifies = new List <GameObject>();
     foreach (GameObject Lifie in GameObject.FindGameObjectsWithTag("Lifie"))
     {
         Lifies.Add(Lifie);
         Debug.Log("added: " + Lifie.GetComponent <Lifie>().Name);
     }
 }
示例#3
0
 public void Reset()
 {
     SelectingTarget    = false;
     SelectedLifie      = null;
     SelectedAttack     = null;
     CancelActionBackup = new Vector3();
     GameObject.Find("MetaObject").GetComponent <MetaObject>().ResetTiles();
     HideActionUI();
     HideAttackUI();
 }
示例#4
0
    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 + ".");
    }
示例#5
0
 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);
 }
示例#6
0
    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.");
    }
示例#7
0
    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();
    }
示例#8
0
    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);
    }
示例#9
0
    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();
        }
    }