Ejemplo n.º 1
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (character != null)
            {
                yield break;
            }

            if (((MapStatus)owner).StatusStates.GetWithDefault <MapCountDownState>().Counter > -1 &&
                ((MapStatus)owner).StatusStates.GetWithDefault <MapCountDownState>().Counter < status.StatusStates.GetWithDefault <MapCountDownState>().Counter)
            {
                ((MapStatus)owner).StatusStates.GetWithDefault <MapCountDownState>().Counter = status.StatusStates.GetWithDefault <MapCountDownState>().Counter;
            }
        }
Ejemplo n.º 2
0
 public void FireMapStatusChanged(MapStatus status)
 {
     this.MapStatus = status;
 }
Ejemplo n.º 3
0
        public override void Apply(T map)
        {
            //TODO: move magic numbers out of here
            EffectTile spawnedChest = new EffectTile(44, true);

            List <Loc> freeTiles = ((IPlaceableGenContext <EffectTile>)map).GetAllFreeTiles();

            int randIndex = map.Rand.Next(freeTiles.Count);
            Loc chosenLoc = freeTiles[randIndex];

            ((IPlaceableGenContext <EffectTile>)map).PlaceItem(chosenLoc, spawnedChest);

            //also put a monster house here
            RandRange       amount     = new RandRange(7, 13);
            int             mobCount   = amount.Pick(map.Rand);
            List <MobSpawn> chosenMobs = new List <MobSpawn>();

            if (map.TeamSpawns.Count > 0)
            {
                for (int ii = 0; ii < mobCount; ii++)
                {
                    List <MobSpawn> exampleList = map.TeamSpawns.Pick(map.Rand).ChooseSpawns(map.Rand);
                    if (exampleList.Count > 0)
                    {
                        chosenMobs.AddRange(exampleList);
                    }
                    if (chosenMobs.Count >= mobCount)
                    {
                        break;
                    }
                }
            }

            if (chosenMobs.Count > 0)
            {
                Rect bounds = new Rect(chosenLoc - new Loc(4), new Loc(9));
                bounds = Rect.Intersect(bounds, new Rect(0, 0, map.Width, map.Height));

                for (int xx = bounds.X; xx < bounds.End.X; xx++)
                {
                    for (int yy = bounds.Y; yy < bounds.End.Y; yy++)
                    {
                        if ((xx == bounds.X || xx == bounds.End.X - 1) && (yy == bounds.Y || yy == bounds.End.Y - 1))
                        {
                            continue;
                        }

                        if (map.GetTile(new Loc(xx, yy)).TileEquivalent(map.WallTerrain))
                        {
                            map.SetTile(new Loc(xx, yy), map.RoomTerrain.Copy());
                        }
                    }
                }

                //cover the room in a check that holds all of the monsters, and covers the room's bounds
                CheckIntrudeBoundsEvent check = new CheckIntrudeBoundsEvent();
                check.Bounds = bounds;
                {
                    MonsterHouseMapEvent house = new MonsterHouseMapEvent();
                    house.Bounds = check.Bounds;
                    foreach (MobSpawn mob in chosenMobs)
                    {
                        house.Mobs.Add(mob.Copy());
                    }
                    check.Effects.Add(house);
                }

                int       intrudeStatus = 33;
                MapStatus status        = new MapStatus(intrudeStatus);
                status.LoadFromData();
                MapCheckState checkState = status.StatusStates.GetWithDefault <MapCheckState>();
                checkState.CheckEvents.Add(check);
                map.Map.Status.Add(intrudeStatus, status);
            }
        }
Ejemplo n.º 4
0
        public void UpdateRemoteSearch(MapStatus status, MiniYaml yaml, Action <MapPreview> parseMetadata = null)
        {
            var newData = innerData.Clone();

            newData.Status = status;
            newData.Class  = MapClassification.Remote;

            if (status == MapStatus.DownloadAvailable)
            {
                try
                {
                    var r = FieldLoader.Load <RemoteMapData>(yaml);

                    // Map download has been disabled server side
                    if (!r.downloading)
                    {
                        newData.Status = MapStatus.Unavailable;
                        return;
                    }

                    newData.Title       = r.title;
                    newData.Categories  = r.categories;
                    newData.Author      = r.author;
                    newData.PlayerCount = r.players;
                    newData.Bounds      = r.bounds;
                    newData.TileSet     = r.tileset;

                    var spawns = new CPos[r.spawnpoints.Length / 2];
                    for (var j = 0; j < r.spawnpoints.Length; j += 2)
                    {
                        spawns[j / 2] = new CPos(r.spawnpoints[j], r.spawnpoints[j + 1]);
                    }
                    newData.SpawnPoints = spawns;
                    newData.GridType    = r.map_grid_type;
                    try
                    {
                        newData.Preview = new Bitmap(new MemoryStream(Convert.FromBase64String(r.minimap)));
                    }
                    catch (Exception e)
                    {
                        Log.Write("debug", "Failed parsing mapserver minimap response: {0}", e);
                        newData.Preview = null;
                    }

                    var playersString = Encoding.UTF8.GetString(Convert.FromBase64String(r.players_block));
                    newData.Players = new MapPlayers(MiniYaml.FromString(playersString));

                    newData.SetRulesetGenerator(modData, () =>
                    {
                        var rulesString             = Encoding.UTF8.GetString(Convert.FromBase64String(r.rules));
                        var rulesYaml               = new MiniYaml("", MiniYaml.FromString(rulesString)).ToDictionary();
                        var ruleDefinitions         = LoadRuleSection(rulesYaml, "Rules");
                        var weaponDefinitions       = LoadRuleSection(rulesYaml, "Weapons");
                        var voiceDefinitions        = LoadRuleSection(rulesYaml, "Voices");
                        var musicDefinitions        = LoadRuleSection(rulesYaml, "Music");
                        var notificationDefinitions = LoadRuleSection(rulesYaml, "Notifications");
                        var sequenceDefinitions     = LoadRuleSection(rulesYaml, "Sequences");
                        var rules = Ruleset.Load(modData, this, TileSet, ruleDefinitions, weaponDefinitions,
                                                 voiceDefinitions, notificationDefinitions, musicDefinitions, sequenceDefinitions);
                        var flagged = Ruleset.DefinesUnsafeCustomRules(modData, this, ruleDefinitions,
                                                                       weaponDefinitions, voiceDefinitions, notificationDefinitions, sequenceDefinitions);
                        return(Pair.New(rules, flagged));
                    });
                }
                catch (Exception e)
                {
                    Log.Write("debug", "Failed parsing mapserver response: {0}", e);
                }

                // Commit updated data before running the callbacks
                innerData = newData;

                if (innerData.Preview != null)
                {
                    cache.CacheMinimap(this);
                }

                if (parseMetadata != null)
                {
                    parseMetadata(this);
                }
            }

            // Update the status and class unconditionally
            innerData = newData;
        }
Ejemplo n.º 5
0
		public void UpdateRemoteSearch(MapStatus status, MiniYaml yaml)
		{
			// Update on the main thread to ensure consistency
			Game.RunAfterTick(() =>
			{
				if (status == MapStatus.DownloadAvailable)
				{
					try
					{
						var r = FieldLoader.Load<RemoteMapData>(yaml);

						// Map download has been disabled server side
						if (!r.downloading)
						{
							Status = MapStatus.Unavailable;
							RuleStatus = MapRuleStatus.Invalid;
							return;
						}

						Title = r.title;
						Type = r.map_type;
						Author = r.author;
						PlayerCount = r.players;
						Bounds = r.bounds;

						var spawns = new List<CPos>();
						for (var j = 0; j < r.spawnpoints.Length; j += 2)
							spawns.Add(new CPos(r.spawnpoints[j], r.spawnpoints[j+1]));
						SpawnPoints = spawns;

						CustomPreview = new Bitmap(new MemoryStream(Convert.FromBase64String(r.minimap)));
					}
					catch (Exception) {}

					if (CustomPreview != null)
						cache.CacheMinimap(this);
				}

				Status = status;
				Class = MapClassification.Remote;
			});
		}
Ejemplo n.º 6
0
 public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
 {
     yield break;
 }
Ejemplo n.º 7
0
        public StatusMenu(int teamSlot)
        {
            int menuWidth = 168;
            List <MenuChoice> flatChoices = new List <MenuChoice>();

            mapIndices = new List <int>();
            foreach (int status in ZoneManager.Instance.CurrentMap.Status.Keys)
            {
                MapStatus statusInstance = ZoneManager.Instance.CurrentMap.Status[status];
                if (!statusInstance.Hidden)
                {
                    Data.MapStatusData statusData = Data.DataManager.Instance.GetMapStatus(status);
                    mapIndices.Add(status);
                    MenuText          statusName = statusName = new MenuText(statusData.GetColoredName(), new Loc(2, 1));
                    MapCountDownState countDown  = statusInstance.StatusStates.GetWithDefault <MapCountDownState>();
                    if (countDown != null && countDown.Counter > 0)
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName, new MenuText("[" + countDown.Counter + "]", new Loc(menuWidth - 8 * 4, 1), DirH.Right)));
                    }
                    else
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName));
                    }
                }
            }
            indices = new List <int>();
            foreach (int status in DungeonScene.Instance.ActiveTeam.Players[teamSlot].StatusEffects.Keys)
            {
                if (Data.DataManager.Instance.GetStatus(status).MenuName)
                {
                    indices.Add(status);
                    MenuText   statusName = null;
                    StackState stack      = DungeonScene.Instance.ActiveTeam.Players[teamSlot].StatusEffects[status].StatusStates.GetWithDefault <StackState>();
                    if (stack != null)
                    {
                        statusName = new MenuText(Data.DataManager.Instance.GetStatus(status).GetColoredName() + (stack.Stack < 0 ? " " : " +") + stack.Stack, new Loc(2, 1));
                    }
                    else
                    {
                        statusName = new MenuText(Data.DataManager.Instance.GetStatus(status).GetColoredName(), new Loc(2, 1));
                    }

                    CountDownState countDown = DungeonScene.Instance.ActiveTeam.Players[teamSlot].StatusEffects[status].StatusStates.GetWithDefault <CountDownState>();
                    if (countDown != null && countDown.Counter > 0)
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName, new MenuText("[" + countDown.Counter + "]", new Loc(menuWidth - 8 * 4, 1), DirH.Right)));
                    }
                    else
                    {
                        flatChoices.Add(new MenuElementChoice(() => { }, true, statusName));
                    }
                }
            }
            List <MenuChoice[]> statuses = SortIntoPages(flatChoices, SLOTS_PER_PAGE);

            summaryMenu = new SummaryMenu(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));

            Description = new DialogueText("", summaryMenu.Bounds.Start + new Loc(GraphicsManager.MenuBG.TileWidth * 2, GraphicsManager.MenuBG.TileHeight),
                                           summaryMenu.Bounds.End.X - GraphicsManager.MenuBG.TileWidth * 4 - summaryMenu.Bounds.X, LINE_SPACE, false);
            summaryMenu.Elements.Add(Description);

            Initialize(new Loc(16, 16), menuWidth, Text.FormatKey("MENU_TEAM_STATUS_TITLE"), statuses.ToArray(), 0, 0, SLOTS_PER_PAGE);
        }
Ejemplo n.º 8
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            //the owner must not be the newly added status
            if (status.ID != owner.GetID() || character != null)
            {
                yield break;
            }

            //remove all other weather effects
            List <int> removingIDs = new List <int>();

            foreach (MapStatus removeStatus in ZoneManager.Instance.CurrentMap.Status.Values)
            {
                bool hasState = false;
                foreach (FlagType state in States)
                {
                    if (removeStatus.StatusStates.Contains(state.FullType))
                    {
                        hasState = true;
                    }
                }
                if (hasState && removeStatus.ID != owner.GetID())
                {
                    removingIDs.Add(removeStatus.ID);
                }
            }
            foreach (int removeID in removingIDs)
            {
                yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.Instance.RemoveMapStatus(removeID, Msg && msg)));
            }
            yield break;
        }
Ejemplo n.º 9
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (status != owner || character != null)
            {
                yield break;
            }

            if (msg)
            {
                DungeonScene.Instance.LogMsg(Message.ToLocal());
                if (Delay)
                {
                    yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(10)));
                }
            }
        }
Ejemplo n.º 10
0
 public MapStatusEventArgs(MapStatus status)
 {
     Status = status;
 }
Ejemplo n.º 11
0
        public void UpdateRemoteSearch(MapStatus status, MiniYaml yaml, Action<MapPreview> parseMetadata = null)
        {
            var newData = innerData.Clone();
            newData.Status = status;
            newData.Class = MapClassification.Remote;

            if (status == MapStatus.DownloadAvailable)
            {
                try
                {
                    var r = FieldLoader.Load<RemoteMapData>(yaml);

                    // Map download has been disabled server side
                    if (!r.downloading)
                    {
                        newData.Status = MapStatus.Unavailable;
                        return;
                    }

                    newData.Title = r.title;
                    newData.Categories = r.categories;
                    newData.Author = r.author;
                    newData.PlayerCount = r.players;
                    newData.Bounds = r.bounds;
                    newData.TileSet = r.tileset;

                    var spawns = new CPos[r.spawnpoints.Length / 2];
                    for (var j = 0; j < r.spawnpoints.Length; j += 2)
                        spawns[j / 2] = new CPos(r.spawnpoints[j], r.spawnpoints[j + 1]);
                    newData.SpawnPoints = spawns;
                    newData.GridType = r.map_grid_type;
                    try
                    {
                        newData.Preview = new Bitmap(new MemoryStream(Convert.FromBase64String(r.minimap)));
                    }
                    catch (Exception e)
                    {
                        Log.Write("debug", "Failed parsing mapserver minimap response: {0}", e);
                        newData.Preview = null;
                    }

                    var playersString = Encoding.UTF8.GetString(Convert.FromBase64String(r.players_block));
                    newData.Players = new MapPlayers(MiniYaml.FromString(playersString));

                    newData.SetRulesetGenerator(modData, () =>
                    {
                        var rulesString = Encoding.UTF8.GetString(Convert.FromBase64String(r.rules));
                        var rulesYaml = new MiniYaml("", MiniYaml.FromString(rulesString)).ToDictionary();
                        var ruleDefinitions = LoadRuleSection(rulesYaml, "Rules");
                        var weaponDefinitions = LoadRuleSection(rulesYaml, "Weapons");
                        var voiceDefinitions = LoadRuleSection(rulesYaml, "Voices");
                        var musicDefinitions = LoadRuleSection(rulesYaml, "Music");
                        var notificationDefinitions = LoadRuleSection(rulesYaml, "Notifications");
                        var sequenceDefinitions = LoadRuleSection(rulesYaml, "Sequences");
                        var rules = Ruleset.Load(modData, this, TileSet, ruleDefinitions, weaponDefinitions,
                            voiceDefinitions, notificationDefinitions, musicDefinitions, sequenceDefinitions);
                        var flagged = Ruleset.DefinesUnsafeCustomRules(modData, this, ruleDefinitions,
                            weaponDefinitions, voiceDefinitions, notificationDefinitions, sequenceDefinitions);
                        return Pair.New(rules, flagged);
                    });
                }
                catch (Exception e)
                {
                    Log.Write("debug", "Failed parsing mapserver response: {0}", e);
                }

                // Commit updated data before running the callbacks
                innerData = newData;

                if (innerData.Preview != null)
                    cache.CacheMinimap(this);

                if (parseMetadata != null)
                    parseMetadata(this);
            }

            // Update the status and class unconditionally
            innerData = newData;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// ${mapping_Map_method_ManipulationPan_D}
 /// </summary>
 public void ManipulationPan(int offsetX, int offsetY, MapStatus mapStatus)
 {
     if (this.panHelper != null && (mapStatus == MapStatus.PanStarted || mapStatus == MapStatus.Panning || mapStatus == MapStatus.PanCompleted))
     {
         this.MapManipulator = MapManipulator.Device;
         this.MapStatus = mapStatus;
         if (mapStatus == MapStatus.Panning)
         {
             this.panHelper.DeltaPan(offsetX, offsetY, TimeSpan.FromMilliseconds(100));
             if (ZoomHelper != null)
             {
                 ZoomHelper.Cancel();
             }
         }
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// ${mapping_Map_method_ManipulationZoom_D}
 /// </summary>
 /// <param name="resolution"></param>
 /// <param name="center"></param>
 /// <param name="mapStatus"></param>
 public void ManipulationZoom(double resolution, Point2D center, MapStatus mapStatus)
 {
     if (this.ZoomHelper != null && (mapStatus == MapStatus.ZoomStarted || mapStatus == MapStatus.Zooming || mapStatus == MapStatus.ZoomCompleted))
     {
         if (panHelper != null)
         {
             panHelper.Cancel();
         }
         if (ZoomHelper != null)
         {
             ZoomHelper.Cancel();
         }
         this.MapManipulator = MapManipulator.Device;
         this.MapStatus = mapStatus;
         targetResolution = resolution;
         this.ZoomHelper.DeltaZoom(resolution, center, TimeSpan.FromMilliseconds(0));
     }
 }
Ejemplo n.º 14
0
        public void UpdateRemoteSearch(MapStatus status, MiniYaml yaml, Action <MapPreview> parseMetadata = null)
        {
            var newData = innerData.Clone();

            newData.Status = status;
            newData.Class  = MapClassification.Remote;

            if (status == MapStatus.DownloadAvailable)
            {
                try
                {
                    var r = FieldLoader.Load <RemoteMapData>(yaml);

                    // Map download has been disabled server side
                    if (!r.downloading)
                    {
                        newData.Status = MapStatus.Unavailable;
                        return;
                    }

                    newData.Title       = r.title;
                    newData.Categories  = r.categories;
                    newData.Author      = r.author;
                    newData.PlayerCount = r.players;
                    newData.Bounds      = r.bounds;
                    newData.TileSet     = r.tileset;
                    newData.MapFormat   = r.mapformat;

                    var spawns = new CPos[r.spawnpoints.Length / 2];
                    for (var j = 0; j < r.spawnpoints.Length; j += 2)
                    {
                        spawns[j / 2] = new CPos(r.spawnpoints[j], r.spawnpoints[j + 1]);
                    }
                    newData.SpawnPoints = spawns;
                    newData.GridType    = r.map_grid_type;
                    try
                    {
                        newData.Preview = new Png(new MemoryStream(Convert.FromBase64String(r.minimap)));
                    }
                    catch (Exception e)
                    {
                        Log.Write("debug", "Failed parsing mapserver minimap response: {0}", e);
                        newData.Preview = null;
                    }

                    var playersString = Encoding.UTF8.GetString(Convert.FromBase64String(r.players_block));
                    newData.Players = new MapPlayers(MiniYaml.FromString(playersString));

                    var rulesString = Encoding.UTF8.GetString(Convert.FromBase64String(r.rules));
                    var rulesYaml   = new MiniYaml("", MiniYaml.FromString(rulesString)).ToDictionary();
                    newData.SetCustomRules(modData, this, rulesYaml);
                }
                catch (Exception e)
                {
                    Log.Write("debug", "Failed parsing mapserver response: {0}", e);
                }

                // Commit updated data before running the callbacks
                innerData = newData;

                if (innerData.Preview != null)
                {
                    cache.CacheMinimap(this);
                }

                parseMetadata?.Invoke(this);
            }

            // Update the status and class unconditionally
            innerData = newData;
        }
Ejemplo n.º 15
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (character != null)
            {
                yield break;
            }

            yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.Instance.RemoveMapStatus(((MapStatus)owner).ID)));
        }
Ejemplo n.º 16
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (status != owner || character != null)
            {
                yield break;
            }

            if (msg)
            {
                SkillData entry = DataManager.Instance.GetSkill(status.StatusStates.GetWithDefault <MapIndexState>().Index);
                DungeonScene.Instance.LogMsg(String.Format(Message.ToLocal(), entry.GetIconName()));
                yield return(new WaitForFrames(GameManager.Instance.ModifyBattleSpeed(10)));
            }
        }
Ejemplo n.º 17
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (character != null)
            {
                yield break;
            }

            yield return(CoroutineManager.Instance.StartCoroutine(DungeonScene.Instance.RemoveMapStatus(status.ID)));

            ZoneManager.Instance.CurrentMap.Status.Add(status.ID, status);
            status.StartEmitter(DungeonScene.Instance.Anims);
        }
Ejemplo n.º 18
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (status != owner || character != null)
            {
                yield break;
            }

            if (status.StatusStates.GetWithDefault <MapCountDownState>().Counter > -1)
            {
                status.Hidden = false;
            }

            yield break;
        }
Ejemplo n.º 19
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (character == null)
            {
                yield break;
            }

            if (character.CurrentForm.Species != ReqSpecies)
            {
                yield break;
            }

            //get the forme it should be in
            int forme = DefaultForme;

            foreach (int weather in WeatherPair.Keys)
            {
                if (ZoneManager.Instance.CurrentMap.Status.ContainsKey(weather))
                {
                    forme = WeatherPair[weather];
                    break;
                }
            }

            if (forme != character.CurrentForm.Form)
            {
                //transform it
                character.Transform(new MonsterID(character.CurrentForm.Species, forme, character.CurrentForm.Skin, character.CurrentForm.Gender));
                DungeonScene.Instance.LogMsg(String.Format(new StringKey("MSG_FORM_CHANGE").ToLocal(), character.GetDisplayName(false)));
            }

            yield break;
        }
Ejemplo n.º 20
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (status != owner || character == null)
            {
                yield break;
            }

            yield return(CoroutineManager.Instance.StartCoroutine(BaseEvent.Apply(owner, ownerChar, character)));
        }
Ejemplo n.º 21
0
    void Update()
    {
        DisplayMap.map.coor[playerRow, playerCol].value = DesignController.FLOOR;
        playerRow = Mathf.RoundToInt(transform.position.x);
        playerCol = Mathf.RoundToInt(transform.position.z);

        //Debug.Log(playerX + "dan y : " + playerY);
        DisplayMap.map.coor[playerRow, playerCol].value = DesignController.PLAYER;
        //Debug.Log(DisplayMap.map.coor[2, 9].value);
        //Map.getSpot(playerY, playerX)= DesignController.PLAYER;

        UnityEngine.UI.Text change = txt.GetComponent <UnityEngine.UI.Text>();
        change.text = "Health : " + health;

        if (health <= 0)
        {
            isDeath = true;
        }


        moveY += 2 * Input.GetAxis("Mouse X");
        moveX -= 2 * Input.GetAxis("Mouse Y");
        transform.eulerAngles = new Vector3(moveX, moveY, 0);

        if (Input.GetKey(KeyCode.W))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(0, 0, Time.deltaTime * 2f));
            }
            transform.Translate(new Vector3(0, 0, Time.deltaTime * 4f));
        }
        if (Input.GetKey(KeyCode.A))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(Time.deltaTime * -2f, 0, 0));
            }
            transform.Translate(new Vector3(Time.deltaTime * -4f, 0, 0));
        }
        if (Input.GetKey(KeyCode.S))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(0, 0, Time.deltaTime * -2f));
            }
            transform.Translate(new Vector3(0, 0, Time.deltaTime * -4f));
        }
        if (Input.GetKey(KeyCode.D))
        {
            //animator.SetBool("isWalk", true);
            if (Input.GetKey(KeyCode.LeftShift))
            {
                transform.Translate(new Vector3(Time.deltaTime * 2f, 0, 0));
            }
            transform.Translate(new Vector3(Time.deltaTime * 4f, 0, 0));
        }

        if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.D))
        {
            //animator.SetBool("isWalk", false);
        }

        if (Input.GetKey(KeyCode.Space))
        {
            transform.Translate(new Vector3(0, Time.deltaTime * 4f, 0));
        }

        if (Input.GetKey(KeyCode.Escape))
        {
            DisplayMap.removeEnemy(DisplayMap.xRand, DisplayMap.yRand);
            DisplayMap.removeTreasure(DisplayMap.xTRand, DisplayMap.yTRand);
            MapStatus.getInstance().setToPlay(false);
            if (MapStatus.getInstance().getChoosenMap() == 1)
            {
                MapStatus.getInstance().setChoosenMap(0);
            }
            TxtController.getInstance().updateText();
            SceneManager.LoadScene("MenuScene");
        }
    }
Ejemplo n.º 22
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (status != owner || character != null)
            {
                yield break;
            }

            ////remove existing spawns
            //ZoneManager.Instance.CurrentMap.TeamSpawns.Clear();

            ShopSecurityState securityState = status.StatusStates.Get <ShopSecurityState>();

            ////add guard spawns
            //for (int ii = 0; ii < securityState.Security.Count; ii++)
            //{
            //    SpecificTeamSpawner post_team = new SpecificTeamSpawner(securityState.Security.GetSpawn(ii).Copy());
            //    ZoneManager.Instance.CurrentMap.TeamSpawns.Add(post_team, securityState.Security.GetSpawnRate(ii));
            //}

            //set spawn rate
            ZoneManager.Instance.CurrentMap.RespawnTime = 0;

            //set spawn max
            ZoneManager.Instance.CurrentMap.MaxFoes = 0;

            //spawn 10 times
            List <Loc> randLocs = ZoneManager.Instance.CurrentMap.GetFreeToSpawnTiles();

            for (int ii = 0; ii < 10; ii++)
            {
                if (randLocs.Count == 0)
                {
                    break;
                }

                int      randIndex = DataManager.Instance.Save.Rand.Next(randLocs.Count);
                Loc      dest      = randLocs[randIndex];
                MobSpawn spawn     = securityState.Security.Pick(DataManager.Instance.Save.Rand);
                yield return(CoroutineManager.Instance.StartCoroutine(PeriodicSpawnEntranceGuards.PlaceGuard(spawn, dest, GuardStatus)));

                randLocs.RemoveAt(randIndex);
            }

            List <Loc> exitLocs = WarpToEndEvent.FindExits();

            //spawn once specifically on the stairs
            foreach (Loc exitLoc in exitLocs)
            {
                Loc?dest = ZoneManager.Instance.CurrentMap.GetClosestTileForChar(null, exitLoc);
                if (!dest.HasValue)
                {
                    continue;
                }

                MobSpawn spawn = securityState.Security.Pick(DataManager.Instance.Save.Rand);
                yield return(CoroutineManager.Instance.StartCoroutine(PeriodicSpawnEntranceGuards.PlaceGuard(spawn, dest.Value, GuardStatus)));
            }
        }
Ejemplo n.º 23
0
 public void StatusChangedCallback(MapStatus mapStatus)
 {
     Debug.Log("status updated: " + mapStatus);
 }
Ejemplo n.º 24
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (status != owner || character != null)
            {
                yield break;
            }

            GameManager.Instance.BGM(BGM, true);
            yield break;
        }
Ejemplo n.º 25
0
    public string GenerateCompleteStatus()
    {
        /* This funciton creates the general status of the map all the players need
         * and sends it to them
         *
         * Mapstatus should contain the following:
         *
         * 1) The Bezier definition of the track
         * 2) The Vertext definition of the walls of the track
         * 3) Placement of all the checkpoints
         *
         */

        MapStatus       mapStatus = new MapStatus();
        TrackController tc        = GameObject.FindObjectOfType <TrackController>();
        RoadMeshCreator pst       = GameObject.FindObjectOfType <RoadMeshCreator>();


        List <Vector3Json> bezierPoints = new List <Vector3Json>();

        foreach (Vector3 point in pst.pathCreator.bezierPath.points)
        {
            bezierPoints.Add(point);
        }

        mapStatus.bezierPoints = bezierPoints;
        mapStatus.roadWidth    = pst.roadWidth;

        GameObject         checkpointHolder = tc.checkpointHolder;
        List <Vector3Json> checkPointPos    = new List <Vector3Json>();
        List <Vector3Json> checkPointRot    = new List <Vector3Json>();

        Bounds checkPointBound = checkpointHolder.transform.GetChild(0).GetComponent <BoxCollider>().bounds;

        for (int i = 0; i < checkpointHolder.transform.childCount; i++)
        {
            Transform t = checkpointHolder.transform.GetChild(i);
            checkPointPos.Add(t.position);
            checkPointRot.Add(t.rotation.eulerAngles);
        }

        mapStatus.checkPointPos  = checkPointPos;
        mapStatus.checkPointRot  = checkPointRot;
        mapStatus.checkpointSize = checkPointBound.size;

        mapStatus.midpoint      = new List <Vector3Json>();
        mapStatus.wallLeft      = new List <Vector3Json>();
        mapStatus.wallRight     = new List <Vector3Json>();
        mapStatus.roadDirection = new List <Vector3Json>();

        VertexPath vertexPath = pst.pathCreator.path;

        Vector3[] pathPoints = vertexPath.localPoints;

        for (int i = 0; i < vertexPath.localPoints.Length; i++)
        {
            Vector3 midPoint   = pathPoints[i];
            Vector3 localRight = Vector3.Cross(Vector3.up, vertexPath.GetTangent(i));

            Vector3 vertSideA = vertexPath.GetPoint(i) - localRight * Mathf.Abs(pst.roadWidth);
            Vector3 vertSideB = vertexPath.GetPoint(i) + localRight * Mathf.Abs(pst.roadWidth);

            mapStatus.midpoint.Add(midPoint);
            mapStatus.wallLeft.Add(vertSideA);
            mapStatus.wallRight.Add(vertSideB);
            mapStatus.roadDirection.Add(vertexPath.GetTangent(i));
        }

        string mapStatusJson = JsonConvert.SerializeObject(mapStatus);

        //Debug.Log(mapStatusJson);

        if (debug)
        {
            for (int i = 1; i < mapStatus.wallLeft.Count; i++)
            {
                // Left
                Vector3 point_l1 = mapStatus.wallRight[i - 1];
                Vector3 point_l2 = mapStatus.wallRight[i];
                Debug.DrawLine(point_l1, point_l2, Color.red);

                // Right
                Vector3 point_r1 = mapStatus.wallLeft[i - 1];
                Vector3 point_r2 = mapStatus.wallLeft[i];
                Debug.DrawLine(point_r1, point_r2, Color.blue);
            }
        }

        return(mapStatusJson);
    }
Ejemplo n.º 26
0
        public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg)
        {
            if (character != null)
            {
                yield break;
            }

            MapCheckState destChecks = ((MapStatus)owner).StatusStates.GetWithDefault <MapCheckState>();
            MapCheckState srcChecks  = status.StatusStates.GetWithDefault <MapCheckState>();

            foreach (SingleCharEvent effect in srcChecks.CheckEvents)
            {
                destChecks.CheckEvents.Add(effect);
            }
        }
Ejemplo n.º 27
0
        //switch view between map and tabs with gps info
        private void mItMap_Click(object sender, EventArgs e)
        {
            if (mapStatus == MapStatus.MAP_VISIBLE)
              {
                  setVisibleImButtons(false);
                  tabControl1.Visible = true;
                  mapStatus = MapStatus.TABS_VISIBLE;
                  pLegend.Visible = false;
                  legendStatus = LegendSatus.LEGEND_NOT_VISIBLE;

                  d3dRenderStatus = D3dRenderStatus.D3D_NOT_RENDER;
                  mItMap.Text = "MAP";
                  if(gpsStatus==GpsStatus.GPS_OPEN)
                      timerSatelliteView.Enabled = true;
                  else
                      timerSatelliteView.Enabled = false;
              }
              else
              {

                  setVisibleImButtons(true);
                  tabControl1.Visible = false;
                  mapStatus = MapStatus.MAP_VISIBLE;
                  pLegend.Visible = false;
                  legendStatus = LegendSatus.LEGEND_NOT_VISIBLE;

                  mItMap.Text = "PROPERTIES";
                  if(drawStatus!= DrawStatus.NOT_DRAW)
                    d3dRenderStatus = D3dRenderStatus.D3D_RENDER;
                  timerSatelliteView.Enabled = false;
              }
        }
Ejemplo n.º 28
0
        public override void Apply(T map)
        {
            //choose a room to cram all the items in
            List <int> possibleRooms = new List <int>();

            for (int ii = 0; ii < map.RoomPlan.RoomCount; ii++)
            {
                FloorRoomPlan testPlan = map.RoomPlan.GetRoomPlan(ii);
                if (!BaseRoomFilter.PassesAllFilters(testPlan, this.Filters))
                {
                    continue;
                }

                //also do not choose a room that contains the start or end
                IViewPlaceableGenContext <MapGenEntrance> entranceMap = map;
                if (Collision.InBounds(testPlan.RoomGen.Draw, entranceMap.GetLoc(0)))
                {
                    continue;
                }
                IViewPlaceableGenContext <MapGenExit> exitMap = map;
                if (Collision.InBounds(testPlan.RoomGen.Draw, exitMap.GetLoc(0)))
                {
                    continue;
                }

                possibleRooms.Add(ii);
            }

            FloorRoomPlan roomPlan  = null;
            Rect          limitRect = Rect.Empty;

            while (possibleRooms.Count > 0)
            {
                int chosenRoom = map.Rand.Next(possibleRooms.Count);
                roomPlan = map.RoomPlan.GetRoomPlan(possibleRooms[chosenRoom]);

                bool[][] eligibilityGrid = new bool[roomPlan.RoomGen.Draw.Width][];
                for (int xx = 0; xx < roomPlan.RoomGen.Draw.Width; xx++)
                {
                    eligibilityGrid[xx] = new bool[roomPlan.RoomGen.Draw.Height];
                    for (int yy = 0; yy < roomPlan.RoomGen.Draw.Height; yy++)
                    {
                        bool eligible = true;
                        Loc  testLoc  = roomPlan.RoomGen.Draw.Start + new Loc(xx, yy);
                        if (map.Tiles[testLoc.X][testLoc.Y].TileEquivalent(map.RoomTerrain) && !map.HasTileEffect(testLoc) &&
                            map.Tiles[testLoc.X][testLoc.Y + 1].TileEquivalent(map.RoomTerrain) && !map.HasTileEffect(new Loc(testLoc.X, testLoc.Y + 1)) &&
                            !map.PostProcGrid[testLoc.X][testLoc.Y].Status[(int)PostProcType.Panel] &&
                            !map.PostProcGrid[testLoc.X][testLoc.Y].Status[(int)PostProcType.Item])
                        {
                            foreach (MapItem item in map.Items)
                            {
                                if (item.TileLoc == testLoc)
                                {
                                    eligible = false;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            eligible = false;
                        }
                        eligibilityGrid[xx][yy] = eligible;
                    }
                }

                List <Rect> candRects = Detection.DetectNLargestRects(eligibilityGrid, 1);
                if (candRects.Count > 0)
                {
                    limitRect = new Rect(roomPlan.RoomGen.Draw.Start + candRects[0].Start, candRects[0].Size);
                    if (limitRect.Size.X >= MIN_SHOP_SIZE && limitRect.Size.Y >= MIN_SHOP_SIZE)
                    {
                        break;
                    }
                }
                possibleRooms.RemoveAt(chosenRoom);
            }

            if (limitRect.Size.X < MIN_SHOP_SIZE || limitRect.Size.Y < MIN_SHOP_SIZE)
            {
                return;
            }

            //randomly roll an actual rectangle within the saferect bounds: between 3x3 and the limit
            Loc  rectSize  = new Loc(map.Rand.Next(MIN_SHOP_SIZE, limitRect.Width + 1), map.Rand.Next(MIN_SHOP_SIZE, limitRect.Height + 1));
            Loc  rectStart = new Loc(limitRect.X + map.Rand.Next(limitRect.Width - rectSize.X + 1), limitRect.Y + map.Rand.Next(limitRect.Height - rectSize.Y + 1));
            Rect safeRect  = new Rect(rectStart, rectSize);

            // place the mat of the shop
            List <Loc> itemTiles = new List <Loc>();

            for (int xx = safeRect.X; xx < safeRect.End.X; xx++)
            {
                for (int yy = safeRect.Y; yy < safeRect.End.Y; yy++)
                {
                    Loc matLoc = new Loc(xx, yy);
                    itemTiles.Add(matLoc);
                    EffectTile effect = new EffectTile(45, true, matLoc);
                    ((IPlaceableGenContext <EffectTile>)map).PlaceItem(matLoc, effect);
                    map.PostProcGrid[matLoc.X][matLoc.Y].Status[(int)PostProcType.Panel] = true;
                    map.PostProcGrid[matLoc.X][matLoc.Y].Status[(int)PostProcType.Item]  = true;
                }
            }

            // place the map status for checking shop items and spawning security guards
            {
                MapStatus status = new MapStatus(SecurityStatus);
                status.LoadFromData();
                ShopSecurityState securityState = new ShopSecurityState();
                for (int ii = 0; ii < Mobs.Count; ii++)
                {
                    securityState.Security.Add(Mobs.GetSpawn(ii).Copy(), Mobs.GetSpawnRate(ii));
                }
                status.StatusStates.Set(securityState);
                status.StatusStates.Set(new MapIndexState(Personality));
                map.Map.Status.Add(SecurityStatus, status);
            }

            // place the mob running the shop
            {
                ExplorerTeam newTeam = new ExplorerTeam();
                newTeam.SetRank(1);
                Character shopkeeper = StartMob.Spawn(newTeam, map);
                Loc       randLoc    = itemTiles[map.Rand.Next(itemTiles.Count)];
                ((IGroupPlaceableGenContext <TeamSpawn>)map).PlaceItems(new TeamSpawn(newTeam, true), new Loc[] { randLoc });
            }

            //choose which item theme to work with
            ItemTheme chosenItemTheme = ItemThemes.Pick(map.Rand);

            //the item spawn list in this class dictates the items available for spawning
            //it will be queried for items that match the theme selected
            List <MapItem> chosenItems = chosenItemTheme.GenerateItems(map, Items);

            //place the items
            for (int ii = 0; ii < chosenItems.Count; ii++)
            {
                if (itemTiles.Count > 0)
                {
                    MapItem item      = new MapItem(chosenItems[ii]);
                    int     randIndex = map.Rand.Next(itemTiles.Count);
                    ((IPlaceableGenContext <MapItem>)map).PlaceItem(itemTiles[randIndex], item);
                    itemTiles.RemoveAt(randIndex);
                }
            }

            //prevent the room from being chosen for anything else
            roomPlan.Components.Set(new NoEventRoom());
        }