public static Outpost CreateOutpostWithId(
            string id,
            OutpostType outpostType,
            Player owner,
            RftVector outpostLocation,
            int initialDrillers = Constants.InitialDrillersPerOutpost
            )
        {
            Outpost outpost = null;

            switch (outpostType)
            {
            case OutpostType.Factory:
                outpost = new Factory(id, outpostLocation, owner);
                break;

            case OutpostType.Generator:
                outpost = new Generator(id, outpostLocation, owner);
                break;

            case OutpostType.Mine:
                outpost = new Mine(id, outpostLocation, owner);
                break;

            case OutpostType.Watchtower:
                outpost = new Watchtower(id, outpostLocation, owner);
                break;

            default:
                return(null);
            }
            outpost.GetComponent <DrillerCarrier>().SetDrillerCount(initialDrillers);
            return(outpost);
        }
Beispiel #2
0
    public Sprite getOutpostSprite(OutpostType type)
    {
        Sprite sprite = Resources.Load <Sprite>("Locations/Unknown");;

        switch (type)
        {
        case OutpostType.Generator:
            sprite = Resources.Load <Sprite>("Locations/GeneratorFill");
            break;

        case OutpostType.Destroyed:
            sprite = Resources.Load <Sprite>("Locations/Destroyed");
            break;

        case OutpostType.Factory:
            sprite = Resources.Load <Sprite>("Locations/FactoryFill");
            break;

        case OutpostType.Mine:
            sprite = Resources.Load <Sprite>("Locations/MineFill");
            break;

        case OutpostType.Watchtower:
            sprite = Resources.Load <Sprite>("Locations/Watchtower");
            break;

        default:
            sprite = Resources.Load <Sprite>("Locations/Unknown");
            break;
        }

        return(sprite);
    }
Beispiel #3
0
 /// <summary>
 /// Outpost constructor
 /// </summary>
 /// <param name="outpostStartPosition">The outpost position</param>
 /// <param name="outpostOwner">The outpost's owner</param>
 /// <param name="type">The type of outpost to create</param>
 public Outpost(string id, RftVector outpostStartPosition, Player outpostOwner, OutpostType type)
 {
     this._id                = id;
     this.Position           = outpostStartPosition;
     _subLauncher            = outpostOwner == null ? new SubLauncher() : new SubLauncher(40);
     this._outpostOwner      = outpostOwner;
     this._specialistManager = new SpecialistManager(100);
     _shieldManager          = new ShieldManager(10);
     this._type              = type;
 }
Beispiel #4
0
        /// <summary>
        /// Generates a set of outposts for one player based on the map generation configurations.
        /// </summary>
        /// <returns>A list of a single player's outposts</returns>
        public List <Outpost> GeneratePlayerOutposts()
        {
            // List of a player's outposts.
            List <Outpost> playerOutposts = new List <Outpost>();

            // setup variables
            double    direction;
            int       distance;
            bool      usableLocation = true;
            int       x, y, idx;
            RftVector vectorDistance;
            RftVector currentOutpostPosition;
            Outpost   currentOutpost, otherOutpost;

            // Loop to generate outposts until the number of generated outposts is valid
            while (playerOutposts.Count < this.OutpostsPerPlayer + this.DormantsPerPlayer)
            {
                // calculate the new outposts location within allowable raidius
                distance  = this.RandomGenerator.NextRand(MinOutpostDistance, MaxSeedDistance);
                direction = this.RandomGenerator.NextDouble() * Math.PI * 2;  // In radians

                // Determine the type of outpost that is generated
                OutpostType type = (OutpostType)this.RandomGenerator.NextRand(0, 5);

                //convert distance & direction into vector X and Y
                x = Convert.ToInt32(Math.Cos(direction) * distance);
                y = Convert.ToInt32(Math.Sin(direction) * distance);
                currentOutpostPosition = new RftVector(map, x, y);

                usableLocation = true;
                // Determine if the generated location is too close to another outpost
                for (idx = 0; idx < playerOutposts.Count & usableLocation; idx++)
                {
                    // Get the X and Y pos to find distance
                    otherOutpost   = playerOutposts[idx];
                    vectorDistance = otherOutpost.GetPosition() - currentOutpostPosition;

                    //ensure that the new location is not too close to other outposts
                    if (vectorDistance.Magnitude() < MinOutpostDistance)
                    {
                        usableLocation = false;
                    }
                }

                // If the location is not too close to another outpost, add the outpost to the list.
                if (usableLocation || playerOutposts.Count == 0)
                {
                    currentOutpost = new Outpost(currentOutpostPosition, type);
                    playerOutposts.Add(currentOutpost);
                }
            }

            // Return list of generated outposts.
            return(playerOutposts);
        }
        /// <summary>
        /// Generates a set of outposts for one player based on the map generation configurations.
        /// </summary>
        /// <returns>A list of a single player's outposts</returns>
        private List <Outpost> GeneratePlayerOutposts()
        {
            // List of a player's outposts.
            List <Outpost> playerOutposts = new List <Outpost>();

            // Loop to generate outposts until the number of generated outposts is valid
            while (playerOutposts.Count < _mapConfiguration.OutpostsPerPlayer + _mapConfiguration.DormantsPerPlayer)
            {
                // calculate the new outposts location within allowable radius
                var distance  = this._randomGenerator.NextDouble() * (_mapConfiguration.MaximumOutpostDistance - _mapConfiguration.MinimumOutpostDistance) + _mapConfiguration.MinimumOutpostDistance;
                var direction = this._randomGenerator.NextDouble() * Math.PI * 2;

                // Determine the type of outpost that is generated
                OutpostType[] validTypes =
                {
                    OutpostType.Factory,
                    OutpostType.Generator,
                    OutpostType.Watchtower,
                };
                OutpostType type = validTypes[this._randomGenerator.NextRand(0, 3)];

                //convert distance & direction into vector X and Y
                var x = Convert.ToInt32(Math.Cos(direction) * distance);
                var y = Convert.ToInt32(Math.Sin(direction) * distance);
                var currentOutpostPosition = new RftVector(_map, x, y);

                var usableLocation = true;
                // Determine if the generated location is too close to another outpost
                int idx;
                for (idx = 0; idx < playerOutposts.Count & usableLocation; idx++)
                {
                    // Get the X and Y pos to find distance
                    var otherOutpost   = playerOutposts[idx];
                    var vectorDistance = otherOutpost.GetComponent <PositionManager>().GetPositionAt(new GameTick(0)) - currentOutpostPosition;

                    //ensure that the new location is not too close to other outposts
                    if (vectorDistance.Magnitude() < _mapConfiguration.MinimumOutpostDistance)
                    {
                        usableLocation = false;
                    }
                }

                // If the location is not too close to another outpost, add the outpost to the list.
                if (usableLocation || playerOutposts.Count == 0)
                {
                    var currentOutpost = CreateOutpost(currentOutpostPosition, type);
                    currentOutpost.GetComponent <IdentityManager>().SetName(_nameGenerator.GetRandomName());
                    playerOutposts.Add(currentOutpost);
                }
            }

            // Return list of generated outposts.
            return(playerOutposts);
        }
Beispiel #6
0
 /// <summary>
 /// Outpost constructor
 /// </summary>
 /// <param name="outpostPosition">The outpost position</param>
 /// <param name="outpostOwner">The outpost's owner</param>
 /// <param name="type">The type of outpost to create</param>
 public Outpost(RftVector outpostPosition, Player outpostOwner, OutpostType type)
 {
     this._id                = IdGenerator.GetNextId();
     this.Position           = outpostPosition;
     this._drillerCount      = outpostOwner == null ? 0 : 40;
     this._outpostOwner      = outpostOwner;
     this._specialistManager = new SpecialistManager(100);
     this._shieldActive      = true;
     this._shieldCapacity    = 10;
     this._shields           = 0;
     this._type              = type;
 }
        /// <summary>
        /// Creates an outpost of the given type and given position.
        /// </summary>
        /// <param name="outpostPosition">Position of outpost</param>
        /// <param name="type"></param>
        /// <returns></returns>
        private Outpost CreateOutpost(RftVector outpostPosition, OutpostType type)
        {
            switch (type)
            {
            case OutpostType.Factory: return(new Factory(_generator.GetNextId(), outpostPosition));

            case OutpostType.Generator: return(new Generator(_generator.GetNextId(), outpostPosition));

            case OutpostType.Mine: return(new Mine(_generator.GetNextId(), outpostPosition));

            case OutpostType.Watchtower: return(new Watchtower(_generator.GetNextId(), outpostPosition));

            default: throw new OutpostTypeException("Invalid Outpost Type");
            }
        }
Beispiel #8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (OutpostType.Length != 0)
            {
                hash ^= OutpostType.GetHashCode();
            }
            if (commonData_ != null)
            {
                hash ^= CommonData.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }