Esempio n. 1
0
 public addoninstance(Ccity _owner, Tcityaddons _type, int _x, int _y)
 {
     x                = _x;
     y                = _y;
     owner            = _owner;
     type             = _type;
     storedproduction = storedhorse = storediron = 0;
     mobtoproduce     = null;
     owner.thiscitysaddons.Add(this);//add this addon to list of addons of its owning city
 }
    void MobAttacksCity(mob attacker, Ccity target)
    {
        int attackroll = lil.randi(attacker.archetype.attacklow, attacker.archetype.attackhigh);
        int defroll    = (target.usedDEFthisturn) ? 0 : (target.defence);

        log.Printline(attacker.archetype.name + " ATK " + attacker.archetype.attacklow + "-" + attacker.archetype.attackhigh +
                      " +" + attacker.attackbonus + " rolls " + attackroll + " =" + (attackroll + attacker.attackbonus), Color.blue);

        if (target.usedDEFthisturn)
        {
            log.Printline(target.name + " DEF 0 (already used this turn)", Color.blue);
        }
        else
        {
            log.Printline(target.name + " DEF " + target.defence);
        }

        int damage = attackroll + attacker.attackbonus - defroll;

        if (damage < 1)
        {
            damage = 0;
        }
        FloatingDamagetoCity(target, attacker, -damage, attacker.archetype.weaponname);
        target.usedDEFthisturn = true;


        //i think it's ok to actually kill the city at this point.
        if (target.hp <= 0)
        {
            log.Printline("The " + ((!target.isfrenzleecity) ? "barbarian ":"") + "city of " + target.name + " was destroyed", Color.red);
            log.Printline("by " + attacker.archetype.name, Color.red);

            if (!target.isfrenzleecity)
            {
                player.score += 100;
            }
            bool won = (map.buildings[target.posx, target.posy] == Etilesprite.BUILDINGS_BARBARIAN_CITADEL);
            map.CityKiller(target.posx, target.posy);
            if (won)
            {
                log.Printline("Peace has been brought to the land.", Color.yellow);
                NextLevel();
            }
        }
    }
    void FloatingDamagetoCity(Ccity victim, mob attacker, int amount, string explanation = "", bool flashsupress = false)
    {
        Color c;

        if (amount == 0)
        {
            c = Color.grey;
        }
        else
        {
            c = (amount < 0) ? Color.red : Color.green;
        }

        FloatingTextItems.Add(new FloatingTextItem(explanation + " " + amount + " hp", victim.posx, victim.posy, c));

        if (attacker == player.mob)
        {
            log.Printline(attacker.archetype.name + " deals " + (-amount) + " to " + victim.name + " [" + explanation + "]", Color.green);
        }

        else
        {
            log.Printline(victim.name, c);
            if (amount <= 0)
            {
                log.Print(" takes ", c);
            }
            else
            {
                log.Print(" gains ", c);
            }

            log.Print(amount + " from " + attacker.archetype.name, c);
            if (explanation.Length > 0)
            {
                log.Print("[" + explanation + "]", c);
            }
        }

        //actually do the damage
        victim.hp += amount;
        c.a        = 0.5f;
        map.gridflashcolour[victim.posx, victim.posy] = c;
        map.gridflashtime[victim.posx, victim.posy]   = Time.time + 0.5f;
    }
Esempio n. 4
0
    public void CityKiller(int x, int y)
    {
        if (buildings[x, y] != Etilesprite.BUILDINGS_CITY && buildings[x, y] != Etilesprite.BUILDINGS_BARBARIAN_CITADEL && buildings[x, y] != Etilesprite.BUILDINGS_BARBARIAN_CAMP)
        {
            Debug.Log("CITY KILLER FAILED. NO CITY BUILDING HERE");
        }

        Ccity target = citythathasinfluence[x, y];//acquire target

        if (target == null)
        {
            Debug.Log("CITY KILLER FAILED NO CCITY HERE");
        }

        foreach (var z in target.influenced)
        {
            influence[z.x, z.y] = null; //set all city influence back to neutral
            //if there's improvements (farm,mine,exploit) on influence i think it's ok to leave them plus it's amusing becaues enemy could azorb them
            //the benefits are basically in the map.currentyield
        }
        //kill addons
        foreach (var z in target.thiscitysaddons)
        {
            buildings[z.x, z.y]    = Etilesprite.EMPTY; //wipe city addon off face of map
            currentyield[z.x, z.y] = yield[z.x, z.y];   //set yield of square back to base tile yield, e.g. losing +10 production from factory
        }
        //kill orphaned units
        foreach (var z in target.unitlist)
        {
            killoffamob(z);
        }

        buildings[x, y]            = Etilesprite.EMPTY;//wipe city off the face of the map!
        citythathasinfluence[x, y] = null;
        //Debug.Log("citylist count before is " + citylist.Count);
        citylist.RemoveAll(r => r == target);
        //Debug.Log("citylist count after is " + citylist.Count);
    }
    bool trytomove(mob m, int deltax, int deltay)//, int rotdir, bool coasting = false)
    {
        bool didsomething = false;

        if (deltax == 1)
        {
            m.reversesprite = false;
        }
        else if (deltax == -1)
        {
            m.reversesprite = true;
        }

        int tentx = m.posx + deltax;
        int tenty = m.posy + deltay;

        //if tentative spot is off map, return
        if (tentx < 0 || tentx >= map.width || tenty < 0 || tenty >= map.height)
        {
            return(false);
        }

        //if tentative spot is goodie hut, let's open it
        if (m == player.mob && map.buildings[tentx, tenty] == Etilesprite.BUILDINGS_GOODIE_HUT && map.itemgrid[tentx, tenty] == null)
        {
            if (!map.havewehadbroomyet && lil.randi(1, 100) <= 20)
            {
                log.Printline("o shit waddup, heer come dat broom!", Color.cyan);
                log.Printline("Bristleboi is on the payroll nao. 10g/turn.", Color.cyan);
                mob mmm = CreateMob(Emobtype.broom, tentx, tenty);
                player.herogoldupkeep += mmm.archetype.upkeepgold;
            }
            else
            {
                log.Printline("You find a bunch of gold", Color.yellow);
                player.gold += 200;
            }
            map.buildings[tentx, tenty] = Etilesprite.EMPTY;
        }


        //if tentative spot is enemy city, attack it
        if (map.buildings[tentx, tenty] == Etilesprite.BUILDINGS_CITY ||
            map.buildings[tentx, tenty] == Etilesprite.BUILDINGS_BARBARIAN_CAMP ||
            map.buildings[tentx, tenty] == Etilesprite.BUILDINGS_BARBARIAN_CITADEL)
        {
            Ccity cc = map.citythathasinfluence[tentx, tenty];
            if (cc != null && (m.hostile_toenemies_currently && !cc.isfrenzleecity ||
                               m.hostile_toplayer_currently && cc.isfrenzleecity))
            {
                MobAttacksCity(m, cc);
                didsomething = true;
                goto okhadfun;
            }
        }


        //if tentative spot has player and we are bad men, attack him!
        if (m.hostile_toplayer_currently && player.posx == tentx && player.posy == tenty)
        {
            MobAttacksMob(m, player.mob);
            didsomething = true;
            goto okhadfun;
        }

        //if spot is empty, move
        if (map.passablecheck(tentx, tenty, m))
        {
            movemob(m, tentx, tenty);
            didsomething = true;
            goto okhadfun;
        }

        //if spot has mob and it's one we hate, attack it
        item_instance i = map.itemgrid[tentx, tenty]; //1.is there a mob there:

        if (i != null && i.ismob &&
            (m.hostile_toenemies_currently && i.mob.hostile_toplayer_currently ||
             m.hostile_toplayer_currently && i.mob.hostile_toenemies_currently))
        {
            MobAttacksMob(m, i.mob);
            didsomething = true;
        }


okhadfun:

        if (m.isplayer)
        {
            TimeEngine = CradleOfTime.player_is_done; return(true);
        }
        return(didsomething);
    }