예제 #1
0
 public void ShipyardWindowPopulate(TradeMission currentTradeMission)
 {
     foreach (BuildingController _shipyard in app.controller.buildings)
     {
         if (_shipyard is ShipyardController)
         {
             app.Notify(GameNotification.ShipyardCreateShipUI, _shipyard, currentTradeMission);
         }
     }
 }
예제 #2
0
    public GameObject CreateTradeRoute()
    {
        if (tradeMissions.Count > 6)
        {
            return(null);
        }

        int        rndFaction = rndGen.Next(factionList.Count);
        GameObject instance   = (GameObject)Instantiate(tradePrefab, new Vector3(0, 0), Quaternion.identity);

        instance.transform.SetParent(tradeWindow.transform, false);
        TradeMission tradeMissionScript = instance.GetComponent <TradeMission> ();

        tradeMissionScript.insignia     = factionList[rndFaction].insignia;
        tradeMissionScript.originalTime = UnityEngine.Random.Range(factionList[rndFaction].minDistance,
                                                                   factionList[rndFaction].maxDistance);
        tradeMissionScript.requestResource = GetRandomTrueResourceRequest(factionList[rndFaction]);
        tradeMissionScript.targetResource  = getRandomTrueResource(factionList[rndFaction]);
        tradeMissionScript.f = factionList[rndFaction];
        tradeMissions.Add(tradeMissionScript);
        timeToNewMission = defaultNewMissionTime;
        return(instance);
    }
예제 #3
0
    public void CreateShipUI(TradeMission mission)
    {
        GameObject shipyardUI;

        shipyardUI = GameObject.Find("ShipyardWindow");
        foreach (ShipyardModel.Ship _ship in gameObject.GetComponent <ShipyardModel>().shipsInShipyard)
        {
            GameObject instance = Instantiate(shipUIPrefab, new Vector3(0, 0), Quaternion.identity) as GameObject;
            instance.transform.SetParent(shipyardUI.transform, false);
            instance.GetComponentInChildren <Text> ().text = _ship.name;
            Button instanceButton = instance.GetComponentInChildren <Button> ();
            if (_ship.theMission != null)
            {
                instanceButton.interactable = false;
            }
            else
            {
                instanceButton.onClick.AddListener(() => mission.StartSailing(_ship));
                instanceButton.onClick.AddListener(() => app.Notify(GameNotification.ShipOnMission, GetComponent <ShipyardController>(), new object[] { mission, _ship }));
                instanceButton.onClick.AddListener(() => app.view.manager.DestroyShipUIInstances());
                instanceButton.onClick.AddListener(() => GameObject.Find("ShipyardWindow").gameObject.SetActive(!GameObject.Find("ShipyardWindow").gameObject.activeSelf));
            }
        }
    }
예제 #4
0
 public void SetMission(Ship _ship, TradeMission _mission)
 {
     _ship.theMission = _mission;
 }
예제 #5
0
 public Ship(string _name, TradeMission p_mission)
 {
     name       = _name;
     theMission = p_mission;
 }
예제 #6
0
 public void RemoveTradeMission(TradeMission _removedTrader)
 {
     Destroy(_removedTrader.gameObject);
     tradeMissions.Remove(_removedTrader);
 }