Ejemplo n.º 1
0
    internal static object CalculateWreckRoi(Looter looter, Wreck wreck, IEnumerable <Unit> otherUnits)
    {
        var turnsToWreck = Math.Ceiling(Utils.GetDistance(looter, wreck) / Utils.CalculateUnitsPerTurnWithCurrentSpeed(looter.Speed));
        var unitCount    = otherUnits.Where(u => Utils.IsInRange(u, wreck, wreck.Radius * 2)).Count();

        return(wreck.WaterAmount - turnsToWreck);
    }
Ejemplo n.º 2
0
        // Play A collision
        void PlayCollision(Collision collision)
        {
            if (collision.B == null)
            {
                // Bounce with border
                collision.A.Bounce();
            }
            else
            {
                Tanker dead = collision.dead();

                if (dead != null)
                {
                    deadTankers.Add(dead);
                    tankers.Remove(dead);
                    units.Remove(dead);

                    Wreck wreck = dead.Die();

                    // If A tanker is too far away, there's no wreck
                    if (wreck != null)
                    {
                        wrecks.Add(wreck);
                    }
                }
                else
                {
                    // Bounce between two units
                    collision.A.Bounce(collision.B);
                }
            }
        }
Ejemplo n.º 3
0
    internal void InitializeUnit(UnitDetails unitDetails)
    {
        switch (unitDetails.UnitType)
        {
        case Constants.ReaperTypeId:
        {
            var reaper = new Reaper(unitDetails);

            if (reaper.PlayerId == 0)
            {
                this.MyReapers.Add(reaper);
            }
            else
            {
                this.EnemyReapers.Add(reaper.PlayerId, reaper);
            }

            break;
        }

        case Constants.DestroyerTypeId:
        {
            var destroyer = new Destroyer(unitDetails);

            if (destroyer.PlayerId == 0)
            {
                this.MyDestroyers.Add(destroyer);
            }
            else
            {
                this.EnemyDestroyers.Add(destroyer.PlayerId, destroyer);
            }

            break;
        }

        case Constants.DoofTypeId:
        {
            var doof = new Doof(unitDetails);

            if (doof.PlayerId == 0)
            {
                this.MyDoofs.Add(doof);
            }
            else
            {
                this.EnemyDoofs.Add(doof.
                                    PlayerId, doof);
            }

            break;
        }

        case Constants.TankerTypeId:
        {
            var tanker = new Tanker(unitDetails);
            this.Tankers.Add(tanker);
            break;
        }

        case Constants.WreckTypeId:
        {
            var wreck = new Wreck(unitDetails);
            this.Wrecks.Add(wreck);
            break;
        }

        case Constants.TarPoolTypeId:
        {
            var pool = new TarPool(unitDetails);
            this.TarPools.Add(pool);
            break;
        }

        case Constants.OilPoolTypeId:
        {
            var pool = new OilPool(unitDetails);
            this.OilPools.Add(pool);
            break;
        }

        default:
            break;
        }
    }