예제 #1
0
    /// <summary>
    /// Creates a new Critter by CritterPlacement info, using the _critters
    /// objects to instantiate the particular one.
    /// </summary>
    /// <param name="created">The CritterPlacement represented the created Critter</param>
    /// <returns></returns>
    public CritterMovement CreateCritter(CritterPlacement created)
    {
        var spawnPos = new Vector2(22.5f, -3.0f);

        var newMovement = Instantiate(_critters[created.Type], spawnPos, Quaternion.identity)
                          .GetComponent <CritterMovement>();

        newMovement.SetTarget(new Vector2(created.Position.X, created.Position.Y) * 3.0f);

        _critterMovements.Add(created.Id, newMovement);

        return(newMovement);
    }
예제 #2
0
 /// <summary>
 /// Sets the target the specified Critter (by id) to a new position
 /// </summary>
 /// <param name="moved">The data representing the Critter's Id and new position</param>
 public void MoveCritter(CritterPlacement moved)
 {
     _critterMovements[moved.Id].SetTarget(
         new Vector2(moved.Position.X, moved.Position.Y) * 3.0f
         );
 }