Example #1
0
        public void SetPlayerPosition(MapCommands direction)
        {
            int position;

            switch (direction)
            {
            case MapCommands.Up:
                position      = this.Position.Y == 0 ? GameEngine.MapHeight - 1 : -1;
                this.Position = new Position(this.Position.X, this.Position.Y + position);
                break;

            case MapCommands.Down:
                position      = this.Position.Y == GameEngine.MapHeight - 1 ? 1 - GameEngine.MapHeight : 1;
                this.Position = new Position(this.Position.X, this.Position.Y + position);
                break;

            case MapCommands.Right:
                position      = this.Position.X == GameEngine.MapWidth ? 1 - GameEngine.MapWidth : 1;
                this.Position = new Position(this.Position.X + position, this.Position.Y);
                break;

            case MapCommands.Left:
                position      = this.Position.X == 0 ? GameEngine.MapWidth - 1 : -1;
                this.Position = new Position(this.Position.X + position, this.Position.Y);
                break;
            }
        }
Example #2
0
        private void MovePlayer(MapCommands direction)
        {
            this.player.SetPlayerPosition(direction);

            Npc enemy =
                this.creepsList
                .FirstOrDefault(
                    e => e.Position.X == this.player.Position.X &&
                    e.Position.Y == this.player.Position.Y &&
                    e.CurrentHealth > 0);

            if (enemy != null)
            {
                this.EnterBattle(enemy);
                return;
            }

            Item item =
                this.items
                .FirstOrDefault(
                    e => e.Position.X == this.player.Position.X &&
                    e.Position.Y == this.player.Position.Y &&
                    e.ItemState == ItemState.Available);

            if (item != null)
            {
                this.player.Inventory.Add(item);
                this.items.Remove(item);
                item.ItemState = ItemState.Collected;
                Renderer.WriteLine(string.Format("You have found a treasure - {0}!", item));
            }
        }
Example #3
0
        public override void Update(TimeSpan timeElapsed)
        {
            if (GameLoop.GSManager._gameState == GameStates.GameState.PlayerTurn)
            {
                MapCommands.CheckKeyboard();
            }

            base.Update(timeElapsed);
        }
Example #4
0
        protected override void OnUpdate()
        {
            var inputDeps = JobHandle.CombineDependencies(Dependency, JobHandle, CrossFrameJobHandle);

            if (CommandsMap.IsCreated)
            {
                JobHandle = CommandsMap.Dispose(inputDeps);
            }
            CommandsMap = new NativeMultiHashMap <MapKey, COMMAND>(0, Allocator.TempJob);

            // Schedule in sequence the realocation of the necessary memory to handle each commands based on the queues sizes.
            // Not done in parallel as the resize consist of an new allocation and a copy.
            // Doing it in parallel would result in branching allocations.
            NativeArray <int> counter = new NativeArray <int>(1, Allocator.TempJob);

            for (int i = 0; i < CommandsQueues.Count; i++)
            {
                JobHandle = new CountCommands()
                {
                    CommandsQueue     = CommandsQueues[i],
                    TotalCommandCount = counter
                }.Schedule(JobHandle);
            }

            JobHandle AllocationJH = new AllocateCommandsMap()
            {
                TotalCommandCount = counter,
                CommandsMap       = CommandsMap
            }.Schedule(JobHandle);

            JobHandle CounterDisposedJH = counter.Dispose(AllocationJH);

            NativeArray <JobHandle> MapperJobHanldes = new NativeArray <JobHandle>(CommandsQueues.Count, Allocator.TempJob);
            var CommandsMapParallelWriter            = CommandsMap.AsParallelWriter();

            for (int i = 0; i < CommandsQueues.Count; i++)
            {
                var jh = new MapCommands()
                {
                    CommandsMap   = CommandsMapParallelWriter,
                    CommandsQueue = CommandsQueues[i]
                }.Schedule(AllocationJH);

                MapperJobHanldes[i] = CommandsQueues[i].Dispose(jh);
            }

            CommandsQueues.Clear();

            Dependency     = JobHandle.CombineDependencies(AllocationJH, JobHandle.CombineDependencies(MapperJobHanldes));
            finalJobHandle = Dependency;
            MapperJobHanldes.Dispose();
        }
 public ViewFlightDataViewModel()
 {
     flightDataRecords           = new ObservableCollection <FlightData>();
     mapMarkers                  = new ObservableCollection <GMapMarker>();
     flightsOnRouteToThisAirport = new ObservableCollection <GMapMarker>();
     // GenerateMapMarkers();
     mapProvider       = GMapProviders.GoogleHybridMap;
     MapZoom           = 4;
     flightRouteShapes = new ObservableCollection <GMapPolygon>();
     errors            = new ObservableCollection <string>();
     setMapLatLong     = new MapCommands(SetMapLatLong);
     showError         = new MapCommands(showErrorView);
 }
        public AirportSearchViewModel()
        {
            filteredAirports = new ObservableCollection <Airport>(AirportDataService.ReadAll());

            SortResultsCommand = new MessageCommands(FilterAirportList);
            selectionMade      = new MapCommands(GatherFlightData);
            setMapLatLong      = new MapCommands(SetMapLatLong);
            addToFavorites     = new MapCommands(AddToFavorites);
            openHelp           = new MapCommands(OpenHelp);
            AirportCount       = "Airport Count = " + filteredAirports.Count().ToString();
            Center             = new PointLatLng(39.9, -84.4);
            MapZoom            = 4;
        }
Example #7
0
        private void ExecuteCommand(MapCommands command, string parameter)
        {
            switch (command)
            {
            case MapCommands.Help:
                ExecuteHelpCommand();
                break;

            case MapCommands.Map:
                this.PrintMap();
                break;

            case MapCommands.Left:
            case MapCommands.Right:
            case MapCommands.Up:
            case MapCommands.Down:
                this.MovePlayer(command);
                break;

            case MapCommands.Status:
                this.ShowStatus();
                break;

            case MapCommands.Clear:
                Renderer.Clear();
                break;

            case MapCommands.Exit:
                this.IsRunning = false;
                Renderer.WriteLine("Bye, noob!");
                break;

            case MapCommands.Class:
                this.ShowClassInfo(parameter);
                break;

            case MapCommands.Race:
                this.ShowRaceInfo(parameter);
                break;

            case MapCommands.Inventory:
                this.player.ShowInventory();
                break;

            case MapCommands.Equip:
                this.player.EquipItem(parameter);
                break;
            }
        }
        public MapScriptLine(String line)
        {
            if (line.Length < 1)
            {
                return;
            }

            SParam = line.Split(' ');
            switch (SParam[0])
            {
            case "fog":
                Command = MapCommands.Fog;
                IParam  = Convert.ToInt32(SParam[1]);
                break;

            case "water":
                Command = MapCommands.Water;
                IParam  = Convert.ToInt32(SParam[1]);
                break;

            case "monster":
                Command = MapCommands.Monster;
                VParam  = new Vector2(
                    Convert.ToSingle(SParam[2]),
                    Convert.ToSingle(SParam[3])
                    );
                break;

            case "makebucket":
                Command = MapCommands.MakeBucket;
                IParam  = Convert.ToInt32(SParam[1]);
                break;

            case "addbucket":
                Command = MapCommands.AddBucket;
                VParam  = new Vector2(Convert.ToSingle(SParam[2]),
                                      Convert.ToSingle(SParam[3]));
                break;

            case "ifnotbucketgoto":
                Command = MapCommands.IfNotBucketGoto;
                break;

            case "wait":
                Command = MapCommands.Wait;
                IParam  = Convert.ToInt32(SParam[1]);
                break;

            case "setflag":
                Command = MapCommands.SetFlag;
                break;

            case "iftruegoto":
                Command = MapCommands.IfTrueGoto;
                break;

            case "iffalsegoto":
                Command = MapCommands.IfFalseGoto;
                break;

            case "setglobalflag":
                Command = MapCommands.SetGlobalFlag;
                break;

            case "ifglobaltruegoto":
                Command = MapCommands.IfGlobalTrueGoto;
                break;

            case "ifglobalfalsegoto":
                Command = MapCommands.IfGlobalFalseGoto;
                break;

            case "stop":
                Command = MapCommands.Stop;
                break;

            case "tag":
                Command = MapCommands.Tag;
                break;

            case "setleftexit":
                Command = MapCommands.SetLeftExit;
                break;

            case "setleftentrance":
                Command = MapCommands.SetLeftEntrance;
                VParam  = new Vector2(Convert.ToSingle(SParam[1]),
                                      Convert.ToSingle(SParam[2]));
                break;

            case "setrightexit":
                Command = MapCommands.SetRightExit;
                break;

            case "setrightentrance":
                Command = MapCommands.SetRightEntrance;
                VParam  = new Vector2(Convert.ToSingle(SParam[1]),
                                      Convert.ToSingle(SParam[2]));
                break;

            case "setintroentrance":
                Command = MapCommands.SetIntroEntrance;
                VParam  = new Vector2(Convert.ToSingle(SParam[1]),
                                      Convert.ToSingle(SParam[2]));
                break;
            }
        }
Example #9
0
        private void MovePlayer(MapCommands direction)
        {
            this.player.SetPlayerPosition(direction);

            Npc enemy =
                this.creepsList
                .FirstOrDefault(
                    e => e.Position.X == this.player.Position.X
                        && e.Position.Y == this.player.Position.Y
                        && e.CurrentHealth > 0);

            if (enemy != null)
            {
                this.EnterBattle(enemy);
                return;
            }

            Item item =
                this.items
                .FirstOrDefault(
                    e => e.Position.X == this.player.Position.X
                        && e.Position.Y == this.player.Position.Y
                        && e.ItemState == ItemState.Available);

            if (item != null)
            {
                this.player.Inventory.Add(item);
                this.items.Remove(item);
                item.ItemState = ItemState.Collected;
                Renderer.WriteLine(string.Format("You have found a treasure - {0}!", item));
            }
        }
Example #10
0
 private void ExecuteCommand(MapCommands command, string parameter)
 {
     switch (command)
     {
         case MapCommands.Help:
             ExecuteHelpCommand();
             break;
         case MapCommands.Map:
             this.PrintMap();
             break;
         case MapCommands.Left:
         case MapCommands.Right:
         case MapCommands.Up:
         case MapCommands.Down:
             this.MovePlayer(command);
             break;
         case MapCommands.Status:
             this.ShowStatus();
             break;
         case MapCommands.Clear:
             Renderer.Clear();
             break;
         case MapCommands.Exit:
             this.IsRunning = false;
             Renderer.WriteLine("Bye, noob!");
             break;
         case MapCommands.Class:
             this.ShowClassInfo(parameter);
             break;
         case MapCommands.Race:
             this.ShowRaceInfo(parameter);
             break;
         case MapCommands.Inventory:
             this.player.ShowInventory();
             break;
         case MapCommands.Equip:
             this.player.EquipItem(parameter);
             break;
     }
 }
 public MapScriptLine(string line)
 {
     if (line.Length < 1) return;
     SParam = line.Split(' ');
     switch (SParam[0])
     {
         case "fog":
             Command = MapCommands.Fog;
             break;
         case "monster":
             Command = MapCommands.Monster;
             VParam = new Vector2(Convert.ToSingle(SParam[2]), Convert.ToSingle(SParam[3]));
             break;
         case "makebucket":
             Command = MapCommands.MakeBucket;
             IParam = Convert.ToInt32(SParam[1]);
             break;
         case "addbucket":
             Command = MapCommands.AddBucket;
             VParam = new Vector2(Convert.ToSingle(SParam[2]), Convert.ToSingle(SParam[3]));
             break;
         case "ifnotbucketgoto":
             Command = MapCommands.IfNotBucketGoto;
             break;
         case "wait":
             Command = MapCommands.Wait;
             IParam = Convert.ToInt32(SParam[1]);
             break;
         case "setflag":
             Command = MapCommands.SetFlag;
             break;
         case "iftruegoto":
             Command = MapCommands.IfTrueGoto;
             break;
         case "iffalsegoto":
             Command = MapCommands.IfFalseGoto;
             break;
         case "setglobalflag":
             Command = MapCommands.SetGlobalFlag;
             break;
         case "ifglobaltruegoto":
             Command = MapCommands.IfGlobalTrueGoto;
             break;
         case "ifglobalfalsegoto":
             Command = MapCommands.IfGlobalFalseGoto;
             break;
         case "stop":
             Command = MapCommands.Stop;
             break;
         case "tag":
             Command = MapCommands.Tag;
             break;
         case "setleftexit":
             Command = MapCommands.SetLeftExit;
             break;
         case "setleftentrance":
             Command = MapCommands.SetLeftEntrance;
             VParam = new Vector2(Convert.ToSingle(SParam[1]), Convert.ToSingle(SParam[2]));
             break;
         case "setrightexit":
             Command = MapCommands.SetRightExit;
             break;
         case "setrightentrance":
             Command = MapCommands.SetRightEntrance;
             VParam = new Vector2(Convert.ToSingle(SParam[1]), Convert.ToSingle(SParam[2]));
             break;
         case "setintroentrance":
             Command = MapCommands.SetIntroEntrance;
             VParam = new Vector2(Convert.ToSingle(SParam[1]), Convert.ToSingle(SParam[2]));
             break;
     }
 }
Example #12
0
 public void SetPlayerPosition(MapCommands direction)
 {
     int position;
     switch (direction)
     {
         case MapCommands.Up:
             position = this.Position.Y == 0 ? GameEngine.MapHeight - 1 : -1;
             this.Position = new Position(this.Position.X, this.Position.Y + position);
             break;
         case MapCommands.Down:
             position = this.Position.Y == GameEngine.MapHeight - 1 ? 1 - GameEngine.MapHeight : 1;
             this.Position = new Position(this.Position.X, this.Position.Y + position);
             break;
         case MapCommands.Right:
             position = this.Position.X == GameEngine.MapWidth ? 1 - GameEngine.MapWidth : 1;
             this.Position = new Position(this.Position.X + position, this.Position.Y);
             break;
         case MapCommands.Left:
             position = this.Position.X == 0 ? GameEngine.MapWidth - 1 : -1;
             this.Position = new Position(this.Position.X + position, this.Position.Y);
             break;
     }
 }