Example #1
0
        public PlayerBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab,
                                   CameraFollower cameraFollower, PlayerHpPresenter playerHpPresenter, RunButtonEvent runButtonEvent,
                                   ScriptText scriptText, ErrorMsg errorMsg, SoundManager soundManager, MeleeAttackEntity meleeAttackEntity,
                                   ProcessScrollViewPresenter processScrollViewPresenter, EventSystemWatcher eventSystemWatcher)
        {
            this.errorMsg          = errorMsg;
            this.playerHpPresenter = playerHpPresenter;
            var botEntity = Object.Instantiate(botEntityPrefab);

            tileMapInfo.PlayerTankTransform = botEntity.transform;
            botEntity.gameObject.layer      = LayerMask.NameToLayer("PlayerBot");
            cameraFollower.SetPlayerPosition(botEntity.transform);
            var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>();

            botEntity.transform.position = tileMapInfo.GetPlayer1StartPosition();
            MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager);
            var gun = new Gun(
                soundManager,
                new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("PlayerBullet")),
                false
                );

            botApplication = new BotApplication.BotApplication(
                botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun, meleeAttackApplication
                );

            javaScriptEngine = new JavaScriptEngine.JavaScriptEngine(botApplication);
            runButtonEvent.AddClickEvent(() => OnRunButtonClick(processScrollViewPresenter, scriptText));
        }
Example #2
0
        public void GetBotTest()
        {
            BoatsClient client = new BoatsClient("");
            BotEntity   bot    = client.GetBot("447229568282132510").GetAwaiter().GetResult();

            output.WriteLine(JsonConvert.SerializeObject(bot));
        }
Example #3
0
 private void Start()
 {
     botEntity                = GetComponent <BotEntity>();
     entityTracker            = GetComponent <EntityTracker>();
     entityTracker.condition  = (entity) => entity.health > 0;
     entityTracker.targetTeam = GameManager.instance.currentGame.GetTarget(botEntity.owner);
 }
Example #4
0
 public PlayGameInitData(
     BotEntity botEntityPrefab,
     BotEntity botEntityPrefab2P,
     CameraFollower cameraFollower,
     PlayerHpPresenter playerHpPresenter,
     TileMapInfo tileMapInfo,
     RunButtonEvent runButtonEvent,
     ScriptText scriptText,
     BulletEntity bulletPrefab,
     ErrorMsg errorMsg,
     SoundManager soundManager,
     MeleeAttackEntity meleeAttackPrefab,
     ProcessScrollViewPresenter processScrollViewPresenter,
     EventSystemWatcher eventSystemWatcher)
 {
     this.botEntityPrefab            = botEntityPrefab;
     this.botEntityPrefab2P          = botEntityPrefab2P;
     this.cameraFollower             = cameraFollower;
     this.playerHpPresenter          = playerHpPresenter;
     this.tileMapInfo                = tileMapInfo;
     this.runButtonEvent             = runButtonEvent;
     this.scriptText                 = scriptText;
     this.bulletPrefab               = bulletPrefab;
     this.errorMsg                   = errorMsg;
     this.soundManager               = soundManager;
     this.meleeAttackPrefab          = meleeAttackPrefab;
     this.processScrollViewPresenter = processScrollViewPresenter;
     this.eventSystemWatcher         = eventSystemWatcher;
 }
    protected override BaseNetworkGameCharacter NewBot()
    {
        var gameInstance = GameInstance.Singleton;
        var botList      = gameInstance.bots;
        var bot          = botList[Random.Range(0, botList.Length)];
        // Get character prefab
        BotEntity botPrefab = gameInstance.botPrefab;

        if (overrideBotPrefab != null)
        {
            botPrefab = overrideBotPrefab;
        }
        // Set character data
        var botEntity = Instantiate(botPrefab);

        botEntity.playerName      = bot.name;
        botEntity.selectHead      = bot.GetSelectHead();
        botEntity.selectCharacter = bot.GetSelectCharacter();
        botEntity.selectWeapons   = bot.GetSelectWeapons();
        if (startWeapons != null && startWeapons.Length > 0)
        {
            botEntity.selectWeapons = GetStartWeapons();
        }
        return(botEntity);
    }
Example #6
0
        internal static void CreateBots()
        {   //BOTS
            var Bot1 = new BotEntity
            {
                UserName        = "******",
                Domain          = "fsdfsdfsdf.onion",
                LastIPAddress   = "10.0.0.1",
                CountryCode     = "HU",
                KeyUnique       = "asdasdasd",
                KeyCertified    = "hash(asdasdasd+key)",
                LastLoggedInUTC = DateTime.UtcNow
            };

            InsertEntity(Bot1);
            var Bot2 = new BotEntity
            {
                UserName        = "******",
                Domain          = "asdasdasd.onion",
                LastIPAddress   = "10.0.0.2",
                CountryCode     = "RU",
                KeyUnique       = "asdasdasdqwe",
                KeyCertified    = "hash(asdasdasdqwe+key)",
                LastLoggedInUTC = DateTime.UtcNow
            };

            InsertEntity(Bot2);
        }
        public async Task <ActionResult> Handle(RegbotCommand request, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            _unitOfWork.BeginTransaction();
            using (var trans = _session.BeginTransaction())
            {
                var Regbot = new BotEntity
                {
                    UserName        = request.UserName,
                    Domain          = request.Domain,
                    CountryCode     = request.CountryCode,
                    KeyUnique       = request.KeyUnique,
                    City            = request.City,
                    CreationDateUTC = request.CreationDateUTC,
                    LastIPAddress   = request.LastIPAddress,
                    LastLoggedInUTC = request.LastLoggedInUTC
                };
                _session.Save(Regbot);
                trans.Commit();
            }

            return(new ActionResult {
                Suceeded = true
            });
        }
        public RemoteHostBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab,
                                       SoundManager soundManager, GameSignalingClient gameSignalingClient,
                                       MeleeAttackEntity meleeAttackEntity, EventSystemWatcher eventSystemWatcher)
        {
            var botEntity = Object.Instantiate(botEntityPrefab);

            tileMapInfo.EnemyTankTransform = botEntity.transform;
            botEntity.gameObject.layer     = LayerMask.NameToLayer("EnemyBot");
            botEntity.transform.position   = tileMapInfo.GetPlayer1StartPosition();
            var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>();
            MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager);
            var gun = new Gun(
                soundManager,
                new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("EnemyBullet")),
                true
                );

            botApplication = new BotApplication.BotApplication(
                botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun,
                meleeAttackApplication, true
                );

            gameSignalingClient.ReceivedClientReceiveSignalData += data =>
            {
                if (data.commandApplyTarget == MatchType.Host)
                {
                    new BotCommandsTransformerService().FromCommandData(data.commandData, botApplication);
                }
            };
        }
 public MoveDirectionCommandObject(BotEntity botEntity, BotEntityAnimation botEntityAnimation, Direction direction,
                                   Action directionChangeCallback)
 {
     this.botEntity               = botEntity;
     this.botEntityAnimation      = botEntityAnimation;
     this.direction               = direction;
     this.directionChangeCallback = directionChangeCallback;
 }
Example #10
0
        public async Task <BotEntity> GetBot(string id)
        {
            Uri uri = new Uri($"{_baseUrl}/bot/{id}");
            HttpResponseMessage res = await _client.GetAsync(uri);

            res.EnsureSuccessStatusCode();

            string req = await res.Content.ReadAsStringAsync();

            BotEntity result = JsonConvert.DeserializeObject <BotEntity>(req);

            return(result);
        }
        public MoveCommandObject(BotEntity botEntity, BotEntityAnimation botEntityAnimation, Direction direction,
                                 Action directionChangeCallback, uint gridDistance, TileMapInfo tileMapInfo,
                                 Action movingCallback, bool noPosFix)
        {
            this.botEntity               = botEntity;
            this.botEntityAnimation      = botEntityAnimation;
            this.direction               = direction;
            this.directionChangeCallback = directionChangeCallback;
            this.tileMapInfo             = tileMapInfo;
            this.movingCallback          = movingCallback;
            this.noPosFix = noPosFix;

            moveCount = (int)(gridDistance * Global.GridSize / speed);
        }
Example #12
0
 public BotApplication(BotEntity botEntity, BotEntityAnimation botEntityAnimation, TileMapInfo tileMapInfo,
                       EventSystemWatcher eventSystemWatcher, Gun gun,
                       MeleeAttackApplication.MeleeAttackApplication meleeAttackApplication, bool noPosFix = false)
 {
     this.botEntity            = botEntity;
     botEntity.HitBulletEvent += (sender, e) => Hp = Hp.DamageHp(1);
     this.botEntityAnimation   = botEntityAnimation;
     this.tileMapInfo          = tileMapInfo;
     Hp = new BotHp(3);
     this.meleeAttackApplication = meleeAttackApplication;
     this.noPosFix           = noPosFix;
     this.eventSystemWatcher = eventSystemWatcher;
     this.gun = gun;
 }
Example #13
0
        public async Task <ActionResult> Handle(UpdateBotStatusCommand request, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            BotEntity botentity = _session.Get <BotEntity>(request.id);

            botentity.LastLoggedInUTC = DateTime.Now;
            using (var trans = _session.BeginTransaction())
            {
                _session.Update(botentity);
                trans.Commit();
            }
            return(new ActionResult {
                Suceeded = true
            });
        }
Example #14
0
        public async Task AddEntity(BotEntity entity)
        {
            var db         = GetDatabase();
            var collection = db.GetCollection <BotEntity>("entities");

            //var entity = new BotEntity
            //{
            //    entityname = "victory",
            //    details = "16th December is the victory day of Bangladesh.",
            //    actiondate = DateTime.Now.ToShortDateString(),
            //    tags = new string[] { "victory day","victory","bijoy dibosh"}
            //};

            await collection.InsertOneAsync(entity);
        }
        public ClientBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab,
                                   CameraFollower cameraFollower, PlayerHpPresenter playerHpPresenter, RunButtonEvent runButtonEvent,
                                   ScriptText scriptText, ErrorMsg errorMsg, SoundManager soundManager,
                                   GameSignalingClient gameSignalingClient,
                                   MeleeAttackEntity meleeAttackEntity, ProcessScrollViewPresenter processScrollViewPresenter,
                                   EventSystemWatcher eventSystemWatcher)
        {
            this.errorMsg          = errorMsg;
            this.playerHpPresenter = playerHpPresenter;
            var botEntity = Object.Instantiate(botEntityPrefab);

            tileMapInfo.PlayerTankTransform = botEntity.transform;
            botEntity.gameObject.layer      = LayerMask.NameToLayer("PlayerBot");
            cameraFollower.SetPlayerPosition(botEntity.transform);
            var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>();

            botEntity.transform.position = tileMapInfo.GetPlayer2StartPosition();
            MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager);
            var gun = new Gun(
                soundManager,
                new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("PlayerBullet")),
                false
                );

            botApplication = new BotApplication.BotApplication(
                botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun,
                meleeAttackApplication, true
                );
            var hookBotApplication = new ClientBotCommandsHook(botApplication, gameSignalingClient);

            javaScriptEngine = new JavaScriptEngine.JavaScriptEngine(hookBotApplication);
            runButtonEvent.AddClickEvent(async() =>
            {
                var tokenSource = new CancellationTokenSource();
                var token       = tokenSource.Token;
                var panel       =
                    processScrollViewPresenter.AddProcessPanel(
                        () => { tokenSource.Cancel(); });
                var task = javaScriptEngine.ExecuteJS(scriptText.GetScriptText(), token, panel.ProcessId);
                await task;
                panel.Dispose();
            });
        }
Example #16
0
 private void Serialize(ServerMessage messageBuffer, BotEntity bot)
 {
     messageBuffer.AppendInteger(bot.Id);
     messageBuffer.AppendString(bot.Info.Name);
     messageBuffer.AppendString(bot.Info.Motto);
     messageBuffer.AppendString(bot.Info.Look.Look);
     messageBuffer.AppendInteger(bot.Id);
     messageBuffer.Append(bot.Position);
     messageBuffer.AppendInteger(0);
     messageBuffer.AppendInteger((int)bot.Type);
     messageBuffer.AppendChar((char)bot.Info.Look.Gender);
     messageBuffer.AppendInteger(bot.Info.Owner.Id);
     messageBuffer.AppendString(bot.Info.Owner.Name);
     messageBuffer.AppendInteger(5);
     messageBuffer.AppendShort(1);
     messageBuffer.AppendShort(2);
     messageBuffer.AppendShort(3);
     messageBuffer.AppendShort(4);
     messageBuffer.AppendShort(5);
 }
Example #17
0
        public CpuBotController(BotEntity botEntityPrefab, TileMapInfo tileMapInfo, BulletEntity bulletPrefab,
                                SoundManager soundManager, MeleeAttackEntity meleeAttackEntity, EventSystemWatcher eventSystemWatcher)
        {
            var botEntity = Object.Instantiate(botEntityPrefab);

            tileMapInfo.EnemyTankTransform = botEntity.transform;
            botEntity.gameObject.layer     = LayerMask.NameToLayer("EnemyBot");
            botEntity.transform.position   = tileMapInfo.GetPlayer2StartPosition();
            var botEntityAnimation = botEntity.GetComponent <BotEntityAnimation>();
            MeleeAttackApplication meleeAttackApplication = new MeleeAttackApplication(meleeAttackEntity, soundManager);
            var gun = new Gun(
                soundManager,
                new BulletEntityCreator(bulletPrefab, LayerMask.NameToLayer("EnemyBullet")),
                true
                );

            botApplication = new BotApplication.BotApplication(
                botEntity, botEntityAnimation, tileMapInfo, eventSystemWatcher, gun, meleeAttackApplication
                );
            cpuAi.Start(botApplication);
        }
Example #18
0
        ///<summary>
        ///calls the update function of each entity
        ///</summary>
        ///<param name="dt">elapsed time since last update</param>
        public void Update(float dt)
        {
            //don't update if the user has paused the game
            if (MyGame.Instance.GamePaused)
                return;

            //update the grave markers
            int curG = 0;
            while (curG < GraveMarkerList.Count)
            {
                GraveMarkerList[curG].Update(dt);
                if (!GraveMarkerList[curG].MarkForDelete)
                {
                    ++curG;
                }
                else
                {
                    EntityManager.Instance.RemoveEntity(GraveMarkerList[curG]);
                    GraveMarkerList.RemoveAt(curG);
                }
            }

            //get any player keyboard input
            //GetPlayerInput();

            //update all the queued searches in the path manager
            _pathManager.UpdateSearches();

            //update any doors
            foreach (Door curDoor in _map.Doors)
            {
                curDoor.Update(dt);
            }

            //update any current projectiles
            int curP = 0;
            while (curP < Projectiles.Count)
            {
                //test for any dead projectiles and remove them if necessary
                if (!Projectiles[curP].IsDead)
                {
                    Projectiles[curP].Update(dt);

                    ++curP;
                }
                else
                {
                    EntityManager.Instance.RemoveEntity(Projectiles[curP]);
                    Projectiles.RemoveAt(curP);
                }
            }

            //update the bots
            bool isSpawnPossible = true;

            foreach (BotEntity curBot in _botList)
            {
                //if this bot's status is 'respawning' attempt to resurrect it
                //from an unoccupied spawn point
                if (curBot.IsSpawning && isSpawnPossible)
                {
                    isSpawnPossible = AttemptToAddBot(curBot);
                }

                //if this bot's status is 'dead' add a grave at its current
                //location then change its status to 'respawning'
                else if (curBot.IsDead)
                {
                    //create a grave
                    AddGrave(curBot.Position);

                    //change its status to spawning
                    curBot.SetSpawning();
                }

                //if this bot is alive update it.
                else if (curBot.IsAlive)
                {
                    curBot.Update(dt);
                }
            }

            //update the triggers
            _map.UpdateTriggerSystem(dt, _botList);

            //if the user has requested that the number of bots be decreased,
            //remove one
            if (!RemoveABot)
                return;

            if (_botList.Count > 0)
            {
                BotEntity bot = _botList[_botList.Count - 1];
                if (bot == _selectedBot)
                {
                    _selectedBot = null;
                }
                NotifyAllBotsOfRemoval(bot);
                _botList.RemoveAt(_botList.Count - 1);
            }

            RemoveABot = false;
        }
 public GetMyPositionCommandObject(TileMapInfo tileMapInfo, BotEntity botEntity)
 {
     this.tileMapInfo = tileMapInfo;
     this.botEntity   = botEntity;
 }
 public Response <int> Update(BotEntity input)
 {
     return(_commandBotAggregate.Update(input));
 }
Example #21
0
 public GetPositionRadianCommandObject(TileMapInfo tileMapInfo, BotEntity botEntity, GridPosition targetGridPos)
 {
     this.tileMapInfo   = tileMapInfo;
     this.botEntity     = botEntity;
     this.targetGridPos = targetGridPos;
 }
Example #22
0
 public Response <int> Update(BotEntity input)
 {
     _commandBotRepo.Update(input);
     return(Response <int> .Create(input.Id, ResponseType.Success));
 }
Example #23
0
 ///<summary>
 ///when a bot is removed from the game by a user all remaining bots
 ///must be notifies so that they can remove any references to that bot
 ///from their memory
 ///</summary>
 ///<param name="removedBot"></param>
 public void NotifyAllBotsOfRemoval(BotEntity removedBot)
 {
     foreach (BotEntity curBot in _botList)
     {
         MessageDispatcher.Instance.DispatchMsg(
             MessageDispatcher.SEND_MSG_IMMEDIATELY,
             MessageDispatcher.SENDER_ID_IRRELEVANT,
             curBot.ObjectId,
             MessageTypes.UserHasRemovedBot,
             removedBot);
     }
 }
Example #24
0
        ///<summary>
        ///temporary method to set selected bot. Will replace when mouse
        ///selection implemented
        ///</summary>
        ///<param name="bot"></param>
        public void TempSetBotSelected(BotEntity bot)
        {
            if (bot == null || bot == _selectedBot)
                return;

            if (_selectedBot != null)
                _selectedBot.Exorcise();

            _selectedBot = bot;
        }
Example #25
0
        ///<summary>
        ///Get all bots in the given bot's field of view.
        ///</summary>
        ///<param name="bot"></param>
        ///<returns>
        ///a list of bots within the given bot's field of view
        ///</returns>
        public List<BotEntity> GetAllBotsInFOV(BotEntity bot)
        {
            List<BotEntity> visibleBots = new List<BotEntity>();

            foreach (BotEntity curBot in _botList)
            {
                //make sure time is not wasted checking against the same
                //bot or against a bot that is dead or re-spawning
                if (curBot == bot || !curBot.IsAlive)
                    continue;

                //first of all test to see if this bot is within the FOV
                if (!Vector2Util.IsSecondInFOVOfFirst(
                        bot.Position,
                        bot.Facing,
                        curBot.Position,
                        bot.FieldOfView))
                    continue;

                //cast a ray from between the bots to test visibility. If the
                //bot is visible add it to the vector
                if (!WallIntersectionTests.DoWallsObstructLineSegment(
                        bot.Position,
                        curBot.Position,
                        _map.Walls))
                {
                    visibleBots.Add(curBot);
                }
            }

            return visibleBots;
        }
Example #26
0
        ///<summary>
        ///Tests if second bot is visible to the first bot
        ///</summary>
        ///<param name="first"></param>
        ///<param name="second"></param>
        ///<returns></returns>
        public bool IsSecondVisibleToFirst(BotEntity first, BotEntity second)
        {
            //if the two bots are equal or if one of them is not alive,
            //return false
            if (!(first == second) && second.IsAlive)
            {
                //first of all test to see if this bot is within the FOV
                if (Vector2Util.IsSecondInFOVOfFirst(
                    first.Position,
                    first.Facing,
                    second.Position,
                    first.FieldOfView))
                {
                    //test the line segment connecting the bots' positions
                    //against the walls. If the bot is visible add it to the list
                    if (!WallIntersectionTests.DoWallsObstructLineSegment(
                        first.Position,
                        second.Position,
                        _map.Walls))
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Example #27
0
        ///<summary>
        ///deletes all the current objects ready for a map load
        ///</summary>
        public void Clear()
        {
            LogUtil.WriteLineIfLogCreate(
                "------------------------------ Cleanup -------------------------------");

            //delete the bots
            foreach (BotEntity curBot in _botList)
            {
                EntityManager.Instance.RemoveEntity(curBot);

                LogUtil.WriteLineIfLogCreate(
                    "Deleting entity id: " + curBot.ObjectId + " of type " +
                    EnumUtil.GetDescription(curBot.EntityType) + "(" +
                    curBot.EntityType + ")");
            }

            //delete any active projectiles
            foreach (Projectile curProjectile in Projectiles)
            {
                EntityManager.Instance.RemoveEntity(curProjectile);

                LogUtil.WriteLineIfLogCreate("Deleting projectile id: " +
                    curProjectile.ObjectId);
            }

            //delete any active graves
            foreach (GraveMarker curGrave in GraveMarkerList)
            {
                EntityManager.Instance.RemoveEntity(curGrave);

                LogUtil.WriteLineIfLogCreate(
                    "Deleting grave id: " + curGrave.ObjectId);
            }

            //clear the containers
            Projectiles.Clear();
            _botList.Clear();
            GraveMarkerList.Clear();
            _selectedBot = null;
        }
Example #28
0
        ///<summary>
        ///constructor with map file parameter
        ///</summary>
        ///<param name="filename"></param>
        public GameManager(string filename)
        {
            Assert.Fatal(null == _instance, "Singleton already created.");
            _instance = this;

            _selectedBot = null;
            MyGame.Instance.GamePaused = false;
            RemoveABot = false;
            _map = null;
            _pathManager = null;

            _botList = new List<BotEntity>();
            _projectiles = new List<Projectile>();
            _graveMarkerList = new List<GraveMarker>();

            _minimapComponentList = new List<MinimapComponent>();

            ////4 upper right minimaps
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(512.0f, 0.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(768.0f, 0.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(512.0f, 256.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(768.0f, 256.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));

            ////4 lower left minimaps
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(0.0f, 512.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(256.0f, 512.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(0.0f, 768.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));
            //_minimapComponentList.Add(CreateMinimapComponent(
            //   new Vector2(0, 0),
            //   new Vector2(64.0f, 64.0f),
            //   new Vector2(256.0f, 768.0f),
            //   new Vector2(256.0f, 256.0f),
            //   true
            //   ));

            try
            {
                Options = MyGame.Instance.Content.Load<OptionsData>(@"data\maps\Options");
            }
            catch (Exception e)
            {
                Assert.Fatal(false,
                    "GameManager.GameManager: Bad options filename -> " + e.Message);
                MyGame.Instance.Exit();
            }

            try
            {
                Parameters = MyGame.Instance.Content.Load<ParameterData>(@"data\maps\Parameters");
            }
            catch (Exception e)
            {
                Assert.Fatal(false,
                    "GameManager.GameManager: Bad parameters filename -> " + e.Message);
                MyGame.Instance.Exit();
            }

            //load in the map
            LoadMap(filename);

            //temp code until mouse select implemented
            //TODO: If we have time we should implement the above comment. If he added the comment I'm sure he'd be pleased to see it implemented ;).
            TempSetBotSelected(BotList[0]);
        }
Example #29
0
        ///<summary>
        ///Attempt to add a bot to the game.
        ///To succeed, one of the spawn points must be clear.
        ///</summary>
        ///<param name="bot"></param>
        ///<returns></returns>
        public bool AttemptToAddBot(BotEntity bot)
        {
            //make sure there are some spawn points available
            if (_map.SpawnPoints.Count <= 0)
            {
                Assert.Fatal(false,
                    "GameManager.AttemptToAddBot: Map has no spawn points!");
                return false;
            }

            //we'll make the same number of attempts to spawn a bot this update
            //as there are spawn points
            int attempts = _map.SpawnPoints.Count;

            while (--attempts >= 0)
            {
                //select a random spawn point
                Vector2 spawnPoint = _map.GetRandomSpawnPoint();

                //check to see if it's occupied
                bool isSpawnPointAvailable = true;
                foreach (BotEntity curBot in _botList)
                {
                    //if the spawn point is unoccupied spawn a bot
                    if (Vector2.Distance(spawnPoint, curBot.Position) <
                        curBot.BoundingRadius)
                    {
                        isSpawnPointAvailable = false;
                    }
                }

                if (!isSpawnPointAvailable)
                    continue;

                bot.Spawn(spawnPoint);

                return true;
            }

            return false;
        }
Example #30
0
        ///<summary>
        ///add a shotgun pellet to the game
        ///</summary>
        ///<param name="shooter"></param>
        ///<param name="target"></param>
        public void AddShotgunPellet(BotEntity shooter, Vector2 target)
        {
            Projectile projectile =
                new ProjectilePellet(shooter, target, new PelletSceneObject());

            Projectiles.Add(projectile);

            projectile.Name = "TempPelletName";
            //register the pellet with the entity manager
            EntityManager.Instance.RegisterEntity(projectile);
            projectile.Name = "PELLET_" + projectile.ObjectId;

            LogUtil.WriteLineIfLogCreate("Adding a shotgun shell " +
                projectile.ObjectId + " at position " + projectile.Position);
        }
Example #31
0
        ///<summary>
        ///add a rocket to the game
        ///</summary>
        ///<param name="shooter"></param>
        ///<param name="target"></param>
        public void AddRocket(BotEntity shooter, Vector2 target)
        {
            Projectile projectile =
                new ProjectileRocket(shooter, target, new RocketSceneObject());

            Projectiles.Add(projectile);

            projectile.Name = "TempRocketName";
            //register the rocket with the entity manager
            EntityManager.Instance.RegisterEntity(projectile);
            projectile.Name = "ROCKET_" + projectile.ObjectId;

            LogUtil.WriteLineIfLogCreate("Adding a rocket " +
                projectile.ObjectId + " at position " + projectile.Position);
        }
Example #32
0
        ///<summary>
        ///add a railgun to the game
        ///</summary>
        ///<param name="shooter"></param>
        ///<param name="target"></param>
        public void AddRailgunSlug(BotEntity shooter, Vector2 target)
        {
            Projectile projectile =
                new ProjectileSlug(shooter, target, new SlugSceneObject());

            Projectiles.Add(projectile);

            projectile.Name = "TempSlugName";
            //register the slug with the entity manager
            EntityManager.Instance.RegisterEntity(projectile);
            projectile.Name = "SLUG_" + projectile.ObjectId;

            LogUtil.WriteLineIfLogCreate("Adding a rail gun slug" +
                projectile.ObjectId + " at position " + projectile.Position);
        }
 public Response <int> Remove(BotEntity input)
 {
     return(_commandBotAggregate.Remove(input));
 }
Example #34
0
        ///<summary>
        ///Adds a bot and switches on the default steering behavior
        ///</summary>
        ///<param name="numBotsToAdd"></param>
        public void AddBots(int numBotsToAdd)
        {
            while (numBotsToAdd-- > 0)
            {
                MinimapComponent minimapComponent = null;
                if (MinimapComponentList.Count > 0)
                {
                    minimapComponent =
                        MinimapComponentList[
                            MinimapComponentList.Count - 1];
                    MinimapComponentList.RemoveAt(
                        MinimapComponentList.Count - 1);
                }
                Teams team = (Teams)(_botList.Count % 4);

                IBotSceneObject botSceneObject;

                //I'm not sure why these if statements were added.
                //I commented them all out, because the constructor for BotStaticSprite caused an asserted error.
                //personally I don't see how any of these if statements make sense... ... owell.

                //if (_botList.Count % 12 < 4)
                //{
                    //create a bot. (its position is irrelevant at this point
                    //because it will not be rendered until it is spawned)
                    botSceneObject = new BotShape3D(team, minimapComponent);
                //}
                /*else if (_botList.Count % 12 < 8)
                {
                    botSceneObject =
                        new BotStaticSprite(team, minimapComponent);
                }
                else
                {
                    botSceneObject =
                        new BotAnimatedSprite(team, minimapComponent);
                }*/

                ((T2DSceneObject)botSceneObject).CreateWithPhysics = true;
                TorqueObjectDatabase.Instance.Register((TorqueObject)botSceneObject);
                ((TorqueObject)botSceneObject).Name = "BOT_" +
                    ((TorqueObject)botSceneObject).ObjectId;

                BotEntity botEntity = new BotEntity(botSceneObject, Vector2.Zero);
                botEntity.Name = ((TorqueObject)botSceneObject).Name;

                //switch the default steering behaviors on
                botEntity.Steering.WallAvoidanceIsOn = true;
                botEntity.Steering.SeparationIsOn = true;

                _botList.Add(botEntity);

                //register the bot with the entity manager
                EntityManager.Instance.RegisterEntity(botEntity);

                LogUtil.WriteLineIfLogCreate("Adding bot <{0}> with ID {1:D}",
                    botEntity.Name, botEntity.ObjectId);
            }
        }
 public Response <int> Add(BotEntity input)
 {
     return(_commandBotAggregate.Add(input));
 }