/// <summary> /// Summon the visit of a trader to a specific landing pad /// The trader will be generated randomly from the trader prototypes. /// </summary> /// <param name="landingPad"></param> public void CallTradeShipTest(Furniture landingPad) { // Currently not using any logic to select a trader TraderPrototype prototype = PrototypeManager.Trader[Random.Range(0, PrototypeManager.Trader.Count - 1)]; Trader trader = prototype.CreateTrader(); GameObject go = new GameObject(trader.Name); go.transform.parent = WorldController.Instance.transform; TraderShipController controller = go.AddComponent <TraderShipController>(); TradeShips.Add(controller); go.transform.position = new Vector3(-10, 50, 0); go.transform.localScale = new Vector3(1, 1, 1); SpriteRenderer spriteRenderer = go.AddComponent <SpriteRenderer>(); spriteRenderer.sprite = SpriteManager.GetSprite("Trader", prototype.AnimationIdle.CurrentFrameName); spriteRenderer.sortingLayerName = "TradeShip"; // TODO: Look into passing more of the work of calling a tradeship off to the controller controller.Init(leavingCoords: new Vector3(100, 50, 0), landingCoords: new Vector3(landingPad.Tile.X + 1, landingPad.Tile.Y + 1, 0), speed: 5f, trader: trader, animationIdle: prototype.AnimationIdle.Clone(), animationFlying: prototype.AnimationFlying.Clone(), renderer: spriteRenderer); }
/// <summary> /// Summon the visit of a trader to a specific landing pad /// The trader will be generated randomly from the trader prototypes. /// </summary> /// <param name="landingPad"></param> public void CallTradeShipTest(Furniture landingPad) { // Currently not using any logic to select a trader TraderPrototype prototype = PrototypeManager.Trader[Random.Range(0, PrototypeManager.Trader.Count - 1)]; Trader trader = prototype.CreateTrader(); GameObject go = new GameObject(trader.Name); go.transform.parent = WorldController.Instance.transform; TraderShipController controller = go.AddComponent <TraderShipController>(); TradeShips.Add(controller); go.transform.position = new Vector3(-10, 50, 0); go.transform.localScale = new Vector3(1, 1, 1); SpriteRenderer spriteRenderer = go.AddComponent <SpriteRenderer>(); spriteRenderer.sprite = SpriteManager.GetSprite("Trader", prototype.Animations["idle"].CurrentFrameName); spriteRenderer.sortingLayerName = "TradeShip"; // TODO: Look into passing more of the work of calling a tradeship off to the controller // TODO: This is a very ugly way to do this, and should instead have use a clone function, after TraderPrototype and Trader are merged controller.Init(leavingCoords: new Vector3(100, 50, 0), landingCoords: new Vector3(landingPad.Tile.X + 1, landingPad.Tile.Y + 1, 0), speed: 5f, trader: trader, animations: new Dictionary <string, SpritenameAnimation>(prototype.Animations), renderer: spriteRenderer); }