コード例 #1
0
    void MoveTo(RoamingNPC t, int x, int y)
    {
        try
        {
            t.Stun(0);
            if (t.CheckStun())
            {
                return;
            }

            if (Random.Range(1, 20) <= 3)
            {
                float randomMessage = Random.Range(0, 1f);

                if (randomMessage <= 0.25f)
                {
                    GameManager.manager.UpdateMessages("You hear a quiet chuckle...");
                }
                else if (randomMessage <= .5f)
                {
                    GameManager.manager.UpdateMessages("You hear a soft, child's voice utter unintelligible words...");
                }
                else if (randomMessage <= 0.75f)
                {
                    GameManager.manager.UpdateMessages("Hafh... ya...");
                }
            }

            if (MapManager.map[x, y].hasPlayer)
            {
                t.runCounter = 20;

                t.runDirection = t.__position - MapManager.playerPos;

                DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);

                return;
            }
            else if ((MapManager.map[x, y].enemy == null || MapManager.map[x, y].enemy.GetComponent <RoamingNPC>().enemySO == t.enemySO) && !t.rooted)
            {
                MapManager.map[t.__position.x, t.__position.y].letter    = "";
                MapManager.map[t.__position.x, t.__position.y].enemy     = null;
                MapManager.map[t.__position.x, t.__position.y].timeColor = new Color(0, 0, 0);

                t.__position = new Vector2Int(x, y);

                if (!t.isInvisible)
                {
                    MapManager.map[x, y].letter = t.EnemySymbol;
                }
                MapManager.map[x, y].enemy     = t.gameObject;
                MapManager.map[x, y].timeColor = t.EnemyColor;

                DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);

                return;
            }
        }
        catch { }

        DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);
    }
コード例 #2
0
    void BlobMoveTo(RoamingNPC t, int x, int y)
    {
        try
        {
            t.Stun(0);
            if (t.CheckStun())
            {
                return;
            }

            Debug.Log("1");

            if ((MapManager.map[x, y].enemy == null || MapManager.map[x, y].enemy.GetComponent <RoamingNPC>().enemySO == t.enemySO) && !t.rooted && MapManager.map[x, y].type != "Wall")
            {
                MapManager.map[t.__position.x, t.__position.y].letter     = "";
                MapManager.map[t.__position.x, t.__position.y].isWalkable = true;
                MapManager.map[t.__position.x, t.__position.y].enemy      = null;
                MapManager.map[t.__position.x, t.__position.y].timeColor  = new Color(0, 0, 0);

                MapManager.map[t.__position.x - 1, t.__position.y].letter     = "";
                MapManager.map[t.__position.x - 1, t.__position.y].isWalkable = true;
                MapManager.map[t.__position.x - 1, t.__position.y].enemy      = null;
                MapManager.map[t.__position.x - 1, t.__position.y].timeColor  = new Color(0, 0, 0);

                MapManager.map[t.__position.x + 1, t.__position.y].letter     = "";
                MapManager.map[t.__position.x + 1, t.__position.y].isWalkable = true;
                MapManager.map[t.__position.x + 1, t.__position.y].enemy      = null;
                MapManager.map[t.__position.x + 1, t.__position.y].timeColor  = new Color(0, 0, 0);

                MapManager.map[t.__position.x, t.__position.y + 1].letter     = "";
                MapManager.map[t.__position.x, t.__position.y + 1].isWalkable = true;
                MapManager.map[t.__position.x, t.__position.y + 1].enemy      = null;
                MapManager.map[t.__position.x, t.__position.y + 1].timeColor  = new Color(0, 0, 0);

                MapManager.map[t.__position.x, t.__position.y - 1].letter     = "";
                MapManager.map[t.__position.x, t.__position.y - 1].isWalkable = true;
                MapManager.map[t.__position.x, t.__position.y - 1].enemy      = null;
                MapManager.map[t.__position.x, t.__position.y - 1].timeColor  = new Color(0, 0, 0);

                t.__position = new Vector2Int(x, y);

                if (!t.isInvisible)
                {
                    MapManager.map[x, y].letter = t.EnemySymbol;
                }
                MapManager.map[x, y].isWalkable = false;
                MapManager.map[x, y].enemy      = t.gameObject;
                MapManager.map[x, y].timeColor  = t.EnemyColor;

                if (MapManager.map[x + 1, y].isWalkable)
                {
                    if (!t.isInvisible)
                    {
                        MapManager.map[x + 1, y].letter = t.EnemySymbol;
                    }
                    MapManager.map[x + 1, y].isWalkable = false;
                    MapManager.map[x + 1, y].enemy      = t.gameObject;
                    MapManager.map[x + 1, y].timeColor  = t.EnemyColor;
                }

                if (MapManager.map[x - 1, y].isWalkable)
                {
                    if (!t.isInvisible)
                    {
                        MapManager.map[x - 1, y].letter = t.EnemySymbol;
                    }
                    MapManager.map[x - 1, y].isWalkable = false;
                    MapManager.map[x - 1, y].enemy      = t.gameObject;
                    MapManager.map[x - 1, y].timeColor  = t.EnemyColor;
                }

                if (MapManager.map[x, y - 1].isWalkable)
                {
                    if (!t.isInvisible)
                    {
                        MapManager.map[x, y - 1].letter = t.EnemySymbol;
                    }
                    MapManager.map[x, y - 1].isWalkable = false;
                    MapManager.map[x, y - 1].enemy      = t.gameObject;
                    MapManager.map[x, y - 1].timeColor  = t.EnemyColor;
                }

                if (MapManager.map[x, y + 1].isWalkable)
                {
                    if (!t.isInvisible)
                    {
                        MapManager.map[x, y + 1].letter = t.EnemySymbol;
                    }
                    MapManager.map[x, y + 1].isWalkable = false;
                    MapManager.map[x, y + 1].enemy      = t.gameObject;
                    MapManager.map[x, y + 1].timeColor  = t.EnemyColor;
                }

                DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);

                return;
            }
        }
        catch { }

        DungeonGenerator.dungeonGenerator.DrawMap(MapManager.map);
    }