示例#1
0
 public Color[] GetColors(CharacterManager.Name name)
 {
     return
         (name == CharacterManager.Name.STRAWBUB ? strawbubColors :
          name == CharacterManager.Name.LAVENDER ? lavenderColors :
          name == CharacterManager.Name.BLUEBUB ? bluebubColors :
          name == CharacterManager.Name.LOREN ? lorenColors :
          name == CharacterManager.Name.GUARD ? guardColors :
          noneColors);
 }
示例#2
0
    public NPC(CharacterManager.Name name = CharacterManager.Name.NONE)
    {
        characterName = name;
        inventory     = new Inventory();
        if (name == CharacterManager.Name.NONE)
        {
            inventory.PopulateRandomInventory();
        }
        else
        {
            inventory.PopulatePresetInventory(CharacterManager.GetCharacterCardPreset(name));
        }
        gameState = new ConversationGrid.GameState
        {
            cards = new List <CardGrid>()
        };

        GetBlockedSpots();
    }
示例#3
0
    private void NewLevel()
    {
        string[] charNames = System.Enum.GetNames(typeof(CharacterManager.Name));

        int characterCount = Random.Range(EncounterCount, charNames.Length + 1);

        int pathCount = Random.Range(1, 1 + Mathf.FloorToInt(characterCount * 1f / EncounterCount));

        List <int>[,] encounters = new List <int> [pathCount, EncounterCount];

        List <int> sourceList = new List <int>();

        for (int i = 0; i < charNames.Length; i++)
        {
            sourceList.Add(i);
        }

        int[] pathWidths = new int[pathCount];

        for (int pathIndex = 0; pathIndex < pathCount; pathIndex++)
        {
            for (int encounterIndex = 0; encounterIndex < EncounterCount; encounterIndex++)
            {
                int i = Random.Range(0, sourceList.Count);
                encounters[pathIndex, encounterIndex] = new List <int> {
                    sourceList[i]
                };
                sourceList.RemoveAt(i);
            }
            pathWidths[pathIndex] = 1;
        }

        while (sourceList.Count > charNames.Length - characterCount)
        {
            int pathIndex      = Random.Range(0, pathCount);
            int encounterIndex = Random.Range(0, EncounterCount);
            encounters[pathIndex, encounterIndex].Add(sourceList[0]);
            sourceList.RemoveAt(0);
            pathWidths[pathIndex] = Mathf.Max(pathWidths[pathIndex], encounters[pathIndex, encounterIndex].Count);
        }

        levelTiles   = new HashSet <Vector2>();
        npcPositions = new Dictionary <CharacterManager.Name, Vector2>();
        int pathPosition = 0;

        for (int pathIndex = 0; pathIndex < pathCount; pathIndex++)
        {
            for (int encounterIndex = 0; encounterIndex < EncounterCount; encounterIndex++)
            {
                List <int> npcs = encounters[pathIndex, encounterIndex];
                for (int i = 0; i < npcs.Count; i++)
                {
                    Vector2 pos   = Vector2.zero;
                    int     baseX = EncounterLength * encounterIndex;
                    int     baseY = (pathPosition + i) * PathSeparation;
                    for (int x = 0; x < EncounterLength; x++)
                    {
                        pos = new Vector2(baseX + x, baseY) * GridSize;
                        levelTiles.Add(pos);
                    }

                    if (i > 0)
                    {
                        for (int y = 0; y <= PathSeparation; y++)
                        {
                            pos = new Vector2(baseX, baseY - y) * GridSize;
                            if (!levelTiles.Contains(pos))
                            {
                                levelTiles.Add(pos);
                            }
                            pos = new Vector2(baseX + EncounterLength, baseY - y) * GridSize;
                            if (!levelTiles.Contains(pos))
                            {
                                levelTiles.Add(pos);
                            }
                        }
                    }

                    Vector2 npcPos          = new Vector2(baseX + Random.Range(1, EncounterLength), baseY) * GridSize;
                    CharacterManager.Name n = (CharacterManager.Name)System.Enum.Parse(typeof(CharacterManager.Name), charNames[npcs[i]]);
                    npcPositions.Add(n, npcPos);
                }
            }
            if (pathIndex < pathCount - 1)
            {
                pathPosition += pathWidths[pathIndex];
            }
        }

        playerPos = new Vector2(0, pathPosition * PathSeparation * GridSize);

        for (int y = 0; y <= pathPosition * PathSeparation; y++)
        {
            Vector2 pos = new Vector2(0, y) * GridSize;
            if (!levelTiles.Contains(pos))
            {
                levelTiles.Add(pos);
            }
            pos = new Vector2(EncounterLength * EncounterCount, y) * GridSize;
            if (!levelTiles.Contains(pos))
            {
                levelTiles.Add(pos);
            }
        }
    }