コード例 #1
0
ファイル: Game.cs プロジェクト: dested/LampLightOnlineSharp
        public Game()
        {
            Instance = this;
            DebugText = new object[0];
            WaypointMaps = new List<WaypointMap>();
            WaypointMaps.Add(new WaypointMap(Color.Red, Color.Green, new Waypoint[] {new Waypoint(4, 4), new Waypoint(40 - 4, 4)}, Scale));
            WaypointMaps.Add(new WaypointMap(Color.Red, Color.Yellow, new Waypoint[] {new Waypoint(4, 4), new Waypoint(20 - 4, 4), new Waypoint(20 - 4, 30 - 4), new Waypoint(40 - 4, 30 - 4)}, Scale));
            WaypointMaps.Add(new WaypointMap(Color.Red, Color.Blue, new Waypoint[] {new Waypoint(4, 4), new Waypoint(4, 30 - 4)}, Scale));
            WaypointMaps.Add(new WaypointMap(Color.Green, Color.Yellow, new Waypoint[] {new Waypoint(40 - 4, 4), new Waypoint(40 - 4, 30 - 4)}, Scale));
            WaypointMaps.Add(new WaypointMap(Color.Green, Color.Blue, new Waypoint[] {new Waypoint(40 - 4, 4), new Waypoint(4, 30 - 4)}, Scale));
            WaypointMaps.Add(new WaypointMap(Color.Yellow, Color.Blue, new Waypoint[] {new Waypoint(40 - 4, 30 - 4), new Waypoint(4, 30 - 4)}, Scale));

            Kingdoms = new JsDictionary<string, Kingdom>();
            Kingdoms["Mike"] = new Kingdom() {
                                                     Color = Color.Red,
                                                     Towers = new List<Tower>() {new KingdomTower(Color.Red, 4, 4)},
                                                     Waypoints = new List<Waypoint>() {
                                                                                              WaypointMaps[0].First(),
                                                                                              WaypointMaps[1].First(),
                                                                                              WaypointMaps[2].First(),
                                                                                      },
                                             };
            Kingdoms["Joe"] = new Kingdom() {
                                                    Color = Color.Green,
                                                    Towers = new List<Tower>() {new KingdomTower(Color.Green, 40 - 4, 4)},
                                                    Waypoints = new List<Waypoint>() {
                                                                                             WaypointMaps[0].Last(),
                                                                                             WaypointMaps[3].First(),
                                                                                             WaypointMaps[4].First(),
                                                                                     }
                                            };
            Kingdoms["Steve"] = new Kingdom() {
                                                      Color = Color.Yellow,
                                                      Towers = new List<Tower>() {
                                                                                         new KingdomTower(Color.Yellow, 40 - 4, 30 - 4),
                                                                                         new SingeShotTower(Color.Yellow, 40 - 6, 30 - 3)
                                                                                 },
                                                      Waypoints = new List<Waypoint>() {
                                                                                               WaypointMaps[1].Last(),
                                                                                               WaypointMaps[3].Last(),
                                                                                               WaypointMaps[5].First(),
                                                                                       }
                                              };
            Kingdoms["Chris"] = new Kingdom() {
                                                      Color = Color.Blue,
                                                      Towers = new List<Tower>() {new KingdomTower(Color.Blue, 4, 30 - 4)},
                                                      Waypoints = new List<Waypoint>() {
                                                                                               WaypointMaps[2].Last(),
                                                                                               WaypointMaps[4].Last(),
                                                                                               WaypointMaps[5].Last(),
                                                                                       }
                                              };
            /*
            KeyboardJS.Instance().Bind.Key("space",
                                           () => {
                                           },
                                           () => { });
            */
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: dested/LampLightOnlineSharp
        public override bool OnClick(Pointer jQueryEvent)
        {
            clicking = true;
            selectedWaypoint = null;
            selectedTower = null;

            Point point = new Point(jQueryEvent.X / Scale.X, jQueryEvent.Y / Scale.Y);
            switch (myClickState.Data) {
                case 0:
                    selectedKingdom = null;

                    foreach (var kingdom in Kingdoms) {
                        foreach (var tower1 in kingdom.Value.Towers) {
                            if (tower1.X == point.X && tower1.Y == point.Y) {
                                selectedKingdom = kingdom.Value;
                                selectedTower = tower1;
                                break;
                            }
                        }
                    }
                    break;
                case 1:
                    foreach (var waypointMap in WaypointMaps) {
                        foreach (var p in waypointMap.Waypoints) {
                            if (p.X == point.X && p.Y == point.Y) {
                                selectedWaypoint = p;
                                break;
                            }
                        }
                    }
                    break;
                case 2:
                    break;
                case 3:

                    if (selectedKingdom != null) {
                        if (TowerExistsAt(point.X, point.Y) == null) {
                            Tower tower = new SingeShotTower(selectedKingdom.Color, point.X, point.Y);
                            selectedKingdom.Towers.Add(selectedTower = tower);
                            tower.Drawer.Init();
                        }
                    }
                    break;
            }

            return base.OnClick(jQueryEvent);
        }