示例#1
0
    /** Creates an avatar for given monster instance. */
    private MonsterController createMonsterAvatar(MDRMonsterInstance monster)
    {
        if (monster == null)
        {
            throw new ArgumentNullException("monster");
        }

        Trace.LogDebug("Creating avatar for {0}", monster);
        Util.Assert(CoM.Instance.MonsterAvatar != null, "Monster avatar not assigned.");

        var avatar = GameObject.Instantiate(CoM.Instance.MonsterAvatar);

        var pixelMesh = avatar.Find("Pixel Mesh");

        Util.Assert(pixelMesh != null, "Monster avatar has no Pixel Mesh child.");

        // Create unique mesh for us.
        pixelMesh.GetComponent <MeshFilter>().mesh = new Mesh();

        var script = avatar.GetComponent <MonsterController>();

        Util.Assert(script != null, "Monster avatar has no MonsterController script.");

        script.Sprite = monster.MonsterType.Portrait;
        script.X      = monster.X;
        script.Y      = monster.Y;
        script.Resync();


        return(script);
    }
示例#2
0
    /**
     * Adds a new monster to the game.
     * @param instance the monster instance to add
     * @param area, the area this monster is associated with.
     * @param location, the location this monster should be spawned at.
     */
    public void AddMonster(MDRMonsterInstance instance, MDRArea area = null, MDRLocation?location = null)
    {
        if (instance == null)
        {
            return;
        }

        if (SpawnManager.Monsters.Contains(instance))
        {
            Trace.LogWarning("Can not add monster instance {0} to table as it already has been added.", instance);
            return;
        }

        // associate monster with area.
        if (area != null)
        {
            CoM.State.SpawnManager.TrackSpawnedMonster(area, instance);
        }

        if (location != null)
        {
            instance.SpawnLocation = location.Value;
            instance.X             = location.Value.X;
            instance.Y             = location.Value.Y;
            //todo: floor instance.Floor = location.Value.Floor
        }

        SpawnManager.Monsters.Add(instance);
    }
示例#3
0
 /** Sets the monster instance to be associdated with the given area. */
 public void TrackSpawnedMonster(MDRArea area, MDRMonsterInstance value)
 {
     if (!SpawnInfo.ContainsKey(area))
     {
         SpawnInfo[area] = new SpawnInformation();
     }
     SpawnInfo[area].SpawnedMonsters.Add(value);
 }
示例#4
0
文件: CoM.cs 项目: bsimser/CoM
 /** Formats monster name, including coloring.  Count is used for detecting plurals. */
 public static string Format(MDRMonsterInstance monster, int count = 1)
 {
     return(Format(monster.MonsterType, count));
 }