/// <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);
        controller.Trader             = trader;
        controller.Speed              = 5f;
        go.transform.position         = new Vector3(-10, 50, 0);
        controller.LandingCoordinates = new Vector3(landingPad.Tile.X + 1, landingPad.Tile.Y + 1, 0);
        controller.LeavingCoordinates = new Vector3(100, 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";
        controller.AnimationFlying      = prototype.AnimationFlying.Clone();
        controller.AnimationIdle        = prototype.AnimationIdle.Clone();
        controller.Renderer             = spriteRenderer;
    }
    public void CallTradeShipTest(Furniture landingPad)
    {
        // Currently not using any logic to select a trader
        TraderPrototype prototype = PrototypeManager.Trader.GetPrototype(Random.Range(0, PrototypeManager.Trader.Count - 1));
        Trader          trader    = prototype.CreateTrader();

        GameObject go = new GameObject(trader.Name);

        go.transform.parent = transform;
        TraderShipController controller = go.AddComponent <TraderShipController>();

        controller.Trader             = trader;
        controller.Speed              = 5f;
        go.transform.position         = new Vector3(-10, 50, 0);
        controller.LandingCoordinates = new Vector3(landingPad.Tile.X + 1, landingPad.Tile.Y + 1, 0);
        controller.LeavingCoordinates = new Vector3(100, 50, 0);
        go.transform.localScale       = new Vector3(1, 1, 1);
        SpriteRenderer spriteRenderer = go.AddComponent <SpriteRenderer>();

        spriteRenderer.sprite           = SpriteManager.current.GetSprite("Trader", "BasicHaulShip");
        spriteRenderer.sortingLayerName = "TradeShip";
    }
Esempio n. 3
0
    /// <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);
    }
Esempio n. 4
0
    /// <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);
    }
Esempio n. 5
0
    public void CallTradeShipTest(NestedObject landingPad)
    {
        Debug.Log("CallTradeShipTest");
        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);
        controller.Trader = trader;
        controller.Speed  = 5f;

        // Figure out where the tradeship comes from, where it lands and where it leaves
        Vector3 entryPoint   = Vector3.zero;
        Vector3 landingPoint = new Vector3(landingPad.Tile.X, landingPad.Tile.Y, 0);
        Vector3 exitPoint    = Vector3.zero;

        System.Random rnd = new System.Random();

        // Get Entry Point
        ShipDir entryDir = GetRandomDirection();

        rnd = new System.Random();
        if (entryDir == ShipDir.N)
        {
            int x = rnd.Next(0, World.Current.Width - 1);
            entryPoint = new Vector3(x, World.Current.Height + 100, 0);
        }
        else if (entryDir == ShipDir.S)
        {
            int x = rnd.Next(0, World.Current.Width - 1);
            entryPoint = new Vector3(x, -100, 0);
        }
        else if (entryDir == ShipDir.E)
        {
            int y = rnd.Next(0, World.Current.Height - 1);
            entryPoint = new Vector3(World.Current.Width + 100, y, 0);
        }
        else if (entryDir == ShipDir.W)
        {
            int y = rnd.Next(0, World.Current.Width - 1);
            entryPoint = new Vector3(-100, y, 0);
        }

        // Get Exit Point
        ShipDir exitDir = GetRandomDirection();

        rnd = new System.Random();
        if (exitDir == ShipDir.N)
        {
            int x = rnd.Next(0, World.Current.Width - 1);
            exitPoint = new Vector3(x, World.Current.Height + 100, 0);
        }
        else if (exitDir == ShipDir.S)
        {
            int x = rnd.Next(0, World.Current.Width - 1);
            exitPoint = new Vector3(x, -100, 0);
        }
        else if (exitDir == ShipDir.E)
        {
            int y = rnd.Next(0, World.Current.Height - 1);
            exitPoint = new Vector3(World.Current.Width + 100, y, 0);
        }
        else if (exitDir == ShipDir.W)
        {
            int y = rnd.Next(0, World.Current.Width - 1);
            exitPoint = new Vector3(-100, y, 0);
        }


        go.transform.position         = entryPoint;
        controller.LandingCoordinates = new Vector3(landingPad.Tile.X + 1, landingPad.Tile.Y + 1, 0);
        controller.LeavingCoordinates = exitPoint;

        go.transform.localScale = new Vector3(1, 1, 1);
        SpriteRenderer spriteRenderer = go.AddComponent <SpriteRenderer>();

        spriteRenderer.sprite           = SpriteManager.GetSprite("Trader", prototype.AnimationIdle.CurrentFrameName);
        spriteRenderer.sortingLayerName = "TradeShip";

        controller.AnimationFlying = prototype.AnimationFlying.Clone();
        controller.AnimationIdle   = prototype.AnimationIdle.Clone();
        controller.Renderer        = spriteRenderer;
    }