Ejemplo n.º 1
0
    // === ACTIONS =================================================================================

    public void MeleeAttack(BattleUnit other)
    {
        battler.AnimateAttack();

        int dmg = 0;

        if (RandUtils.Chance(Get(StatTag.ACC) / 100.0f))
        {
            battler.GetComponent <CharaEvent>().FaceToward(other.battler.GetComponent <MapEvent>());
            dmg = (int)Get(StatTag.DMG);
            battle.Log(this + " attacked " + other + " for " + dmg + " damage.");
            if (Get(StatTag.ATTACKS) < 1)
            {
                isRecovering = true;
            }
            else if (Get(StatTag.ATTACKS) > 1)
            {
                canActAgain = true;
            }
        }
        else
        {
            battle.Log(this + " missed " + other + ".");
        }

        if (dmg > 0)
        {
            other.TakeDamage(dmg, battler.damageAnimation);
        }
    }
Ejemplo n.º 2
0
    public List <Encounter> GenerateEncounters(int level)
    {
        //int targetDanger;
        //if (level < firstLevelDangerOverrides.Count) {
        //    targetDanger = firstLevelDangerOverrides[level];
        //} else {
        //    targetDanger = baseDanger + level * dangerPerLevel;
        //}

        List <Encounter> results = new List <Encounter>();
        int added  = 0;
        int target = Random.Range(enemiesLow, enemiesHigh);

        while (results.Count < target)
        {
            RandUtils.Shuffle(encounters);
            Encounter toAdd = null;
            foreach (Encounter encounter in encounters)
            {
                if (level >= encounter.levelMin &&
                    level <= encounter.levelMax &&
                    RandUtils.Chance(encounter.rarity / 100.0f))
                {
                    toAdd  = encounter;
                    added += 1;
                    break;
                }
            }
            if (toAdd != null)
            {
                results.Add(toAdd);
            }
        }
        return(results);
    }
Ejemplo n.º 3
0
 private Item GeneratePickup(int level)
 {
     if (level < 2)
     {
         return(null);
     }
     if (RandUtils.Chance(0.7f))
     {
         return(scissors);
     }
     else
     {
         return(eraser);
     }
 }
Ejemplo n.º 4
0
    public Skill(Scroll scroll)
    {
        this.scroll = scroll;
        data        = scroll.data;
        mods        = new List <SkillModifier>();
        foreach (SkillModifier.Type type in scroll.mods)
        {
            mods.Add(new SkillModifier(type));
        }

        // generation
        if (data.prohibitedToBeCD)
        {
            costMP = data.baseCost;
        }
        else if (data.prohibitedToBeMP)
        {
            costCD = data.baseCost;
        }
        else if (RandUtils.Chance(0.7f))
        {
            costMP = data.baseCost;
        }
        else
        {
            costCD = Mathf.CeilToInt(data.baseCost / 8.0f);
        }

        pageCost     = data.basePages;
        longformName = "";
        foreach (SkillModifier mod in mods)
        {
            longformName = mod.MutateName(longformName);
            pageCost     = mod.MutatePages(pageCost);
            if (costMP > 0)
            {
                costMP = mod.MutateCost(costMP);
            }
            else
            {
                costCD = mod.MutateCost(costCD);
            }
        }
        longformName = skillName + " [ " + pageCost + "pg " + (costMP > 0 ? costMP + "mp" : costCD + "cd") + " ] " + longformName;
    }
Ejemplo n.º 5
0
    private Scroll GenerateScroll(int level)
    {
        int modCount = 0;

        if (level >= 8)
        {
            modCount = RandUtils.Chance(0.6f) ? 1 : 0;
        }
        else if (level >= 4)
        {
            modCount = RandUtils.Chance(0.35f) ? 1 : 0;
        }
        else
        {
            modCount = RandUtils.Chance(0.1f) ? 1 : 0;
        }

        List <SkillModifier.Type> toApply = new List <SkillModifier.Type>();
        List <SkillModifier.Type> mods    = new List <SkillModifier.Type>(
            (SkillModifier.Type[])System.Enum.GetValues(typeof(SkillModifier.Type)));

        while (toApply.Count < modCount)
        {
            SkillModifier.Type mod = mods[Random.Range(0, mods.Count)];
            if (!toApply.Contains(mod))
            {
                toApply.Add(mod);
            }
        }

        Scroll scroll = Instantiate(this.scroll);

        scroll.mods = toApply;
        while (scroll.data == null)
        {
            SkillData skill = skills[Random.Range(0, skills.Count)];
            if (RandUtils.Chance((skill.rarity - level) / 100.0f))
            {
                scroll.data = skill;
            }
        }

        return(scroll);
    }
Ejemplo n.º 6
0
    public void FillWithVault(TacticsTerrainMesh mesh)
    {
        if (RandUtils.Chance(0.4f))
        {
            return;
        }
        if (vaults == null)
        {
            vaults = Resources.Load <VaultList>(VaultsPath);
        }
        bool flipX = RandUtils.Flip();
        bool flipY = RandUtils.Flip();
        TacticsTerrainMesh vault = vaults.vaults[Random.Range(0, vaults.vaults.Count)];

        for (int trueY = 0; trueY < cell.sizeY; trueY += 1)
        {
            for (int trueX = 0; trueX < cell.sizeX; trueX += 1)
            {
                int x = flipX ? trueX : (cell.sizeX - 1 - trueX);
                int y = flipY ? trueY : (cell.sizeY - 1 - trueY);
                mesh.SetHeight(cell.startX + x, cell.startY + y,
                               mesh.HeightAt(cell.startX + x, cell.startY + y) + vault.HeightAt(x, y) - 1.0f);
                Tile topTile = vault.TileAt(x, y);
                if (topTile != mesh.defaultTopTile)
                {
                    mesh.SetTile(cell.startX + x, cell.startY + y, topTile);
                }
                for (float h = 0.0f; h < vault.HeightAt(x, y); h += 0.5f)
                {
                    foreach (OrthoDir dir in System.Enum.GetValues(typeof(OrthoDir)))
                    {
                        Tile t = vault.TileAt(x, y, h, dir);
                        if (t != mesh.defaultFaceTile)
                        {
                            mesh.SetTile(cell.startX + x, cell.startY + y, mesh.HeightAt(x, y) - 1 + h, dir, t);
                        }
                    }
                }
            }
        }
    }