Exemple #1
0
 // Use this for initialization
 void Start()
 {
     foreach (Transform child in transform)
     {
         if (child.name.Equals("ChoiceGuarantee"))
         {
             choiceGuarantee = child.GetComponent <Button>();
         }
         if (child.name.Equals("ChoiceRisk"))
         {
             choiceRisk = child.GetComponent <Button>();
         }
     }
     choiceGuarantee.onClick.AddListener(() => gameObject.SetActive(false));
     choiceRisk.onClick.AddListener(() => gameObject.SetActive(false));
     choiceGuarantee.onClick.AddListener(() => ChoiceGuarantee());
     choiceRisk.onClick.AddListener(() => ChoiceRisk());
     ship = (ShipyardModel.Ship)data[0];
     foreach (Transform child in transform)
     {
         if (child.name == "ContentText")
         {
             customText = child.GetComponent <Text>().text;
             customText = customText.Replace("[randomfaction]", Factions.current.factionList[Random.Range(0, Factions.current.factionList.Count)].name);
             customText = customText.Replace("[shipname]", ship.name);
             child.GetComponent <Text>().text = customText;
         }
     }
 }
    // Use this for initialization
    void Start()
    {
        _ship = new ShipyardModel.Ship("HMS Victory");
        foreach (BuildingController building in app.controller.buildings)
        {
            if (building is ShipyardController)
            {
                _ship = building.GetComponent <ShipyardModel>().shipsInShipyard[0];

                break;
            }
        }
        foreach (Transform _child in transform)
        {
            if (_child.name.Equals("choiceAgree"))
            {
                choiceAgreeButton = _child.GetComponent <Button>();
            }
            if (_child.name.Equals("ContentText"))
            {
                _child.GetComponent <Text>().text = _child.GetComponent <Text>().text.Replace("[shipname]", _ship.name);
            }
        }
        choiceAgreeButton.onClick.AddListener(() => ChoiceAgree());
        disableButton.onClick.AddListener(() => VascoAnger(true));
    }
    public override void OnNotification(string p_event_path, object p_target, params object[] p_data)
    {
        base.OnNotification(p_event_path, p_target, p_data);
        if (this != p_target)
        {
            return;
        }
        switch (p_event_path)
        {
        case GameNotification.ShipyardCreateShipUI:
            GetComponent <ShipyardView>().CreateShipUI(p_data[0] as TradeMission);
            return;

        case GameNotification.ShipTravelEvent:
            string eventName = EventSystem.RandomTravelEvent("TravelEvent");
            if (eventName.Equals("none loaded"))
            {
                return;
            }
            EventSystem.OccurEvent(eventName, p_data);
            return;

        case GameNotification.ShipOnMission:
            int index = GetComponent <ShipyardModel>().shipsInShipyard.IndexOf((ShipyardModel.Ship)p_data[1]);
            ShipyardModel.Ship newShip = new ShipyardModel.Ship(((ShipyardModel.Ship)p_data[1]).name, p_data[0] as TradeMission);
            GetComponent <ShipyardModel>().shipsInShipyard[index] = newShip;
            return;
        }
    }
    public void StartSailing(ShipyardModel.Ship _ship)
    {
        switch (requestResource.ReturnTypeofMax())
        {
        case 0:
            app.model.manager.addToResource(0, -requestResource.ReturnMax());
            break;

        case 1:
            app.model.manager.addToResource(1, -requestResource.ReturnMax());
            break;

        case 2:
            app.model.manager.addToResource(2, -requestResource.ReturnMax());
            break;
        }
        app.model.manager.currentShips++;
        sailing = true;
        button.GetComponent <Image> ().color = Color.red;
        button.transform.Find("Text").GetComponent <Text> ().text = "Cancel Ship";
        button.GetComponent <Button> ().onClick.RemoveListener(action);
        action -= CheckValidityOfSailing;
        action += CancelSailing;
        button.GetComponent <Button> ().onClick.AddListener(action);
    }
 protected override void OnMouseDown()
 {
     if (GetComponent <ShipyardModel>().eventShip != null)
     {
         ShipyardModel.Ship newShip = GetComponent <ShipyardModel>().eventShip;
         app.Notify(GameNotification.ShipTravelEvent, this, newShip);
         GetComponent <ShipyardView>().SetDefaultSprite();
         GetComponent <ShipyardModel>().eventShip = null;
         AudioManager.Instance.RandomizeSfx(shipyardSFX);
     }
 }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        rndType = Random.Range(0, 3);
        string customText;

        ship = (ShipyardModel.Ship)data[0];
        foreach (Transform child in transform)
        {
            if (child.name == "ContentText")
            {
                customText = child.GetComponent <Text>().text;
                customText = customText.Replace("[faction]", ship.theMission.f.name);
                customText = customText.Replace("[type]", ResourceBundle.TypePluralToString(rndType));
                child.GetComponent <Text>().text = customText;
            }
        }
        disableButton.onClick.AddListener(() => AddTresure());
    }
Exemple #7
0
    // Use this for initialization
    void Start()
    {
        int rndRandom = Random.Range(1, 3);

        ship = (ShipyardModel.Ship)data[0];
        foreach (Transform child in transform)
        {
            if (child.name == "ContentText")
            {
                customText = child.GetComponent <Text>().text;
                customText = customText.Replace("[faction]", ship.theMission.f.name);
                customText = customText.Replace("[shipname]", ship.name);
                customText = customText.Replace("[turns]", (rndRandom).ToString());
                child.GetComponent <Text>().text = customText;
            }
        }
        ship.theMission.SailTick(rndRandom);
    }
Exemple #8
0
    // Use this for initialization
    void Start()
    {
        int rndRandom = Random.Range(2, 5);

        ship = (ShipyardModel.Ship)data[0];
        foreach (Transform child in transform)
        {
            if (child.name == "ContentText")
            {
                customText = child.GetComponent <Text>().text;
                customText = customText.Replace("[faction]", ship.theMission.f.name);
                customText = customText.Replace("[shipname]", ship.name);
                customText = customText.Replace("[percent]", (rndRandom * 10).ToString());
                child.GetComponent <Text>().text = customText;
            }
        }
        ship.theMission.requestResource *= (1 - (((float)rndRandom) / 10));
    }
    // Use this for initialization
    void Start()
    {
        foreach (Transform child in transform)
        {
            if (child.name.Equals("ChoiceGuarantee"))
            {
                choiceGuarantee = child.GetComponent <Button>();
            }
            if (child.name.Equals("ChoiceRisk"))
            {
                choiceRisk = child.GetComponent <Button>();
            }
        }
        choiceGuarantee.onClick.AddListener(() => gameObject.SetActive(false));
        choiceRisk.onClick.AddListener(() => gameObject.SetActive(false));
        choiceGuarantee.onClick.AddListener(() => ChoiceGuarantee());
        choiceRisk.onClick.AddListener(() => ChoiceRisk());
        ship = (ShipyardModel.Ship)data[0];

        float rndModifier = Random.Range(0.2f, 3f);
        int   rndType     = Random.Range(0, 3);

        changeBundle = new ResourceBundle(rndType, (ship.theMission.requestResource *= rndModifier).ReturnMax());


        foreach (Transform child in transform)
        {
            if (child.name == "ContentText")
            {
                customText = child.GetComponent <Text>().text;
                customText = customText.Replace("[faction]", ship.theMission.f.name);
                customText = customText.Replace("[shipname]", ship.name);
                customText = customText.Replace("[amount]", changeBundle.ReturnMax().ToString());
                customText = customText.Replace("[type]", changeBundle.ReturnStringofMax());
                customText = customText.Replace("[amountcargo]", ship.theMission.requestResource.ReturnMax().ToString());
                customText = customText.Replace("[typecargo]", ship.theMission.requestResource.ReturnStringofMax());
                child.GetComponent <Text>().text = customText;
            }
        }
    }
 public void CreateShip(string _name)
 {
     ShipyardModel.Ship _ship = new ShipyardModel.Ship(_name);
     GetComponent <ShipyardModel>().shipsInShipyard.Add(_ship);
 }
Exemple #11
0
 // Use this for initialization
 void Start()
 {
     shipsInShipyard = new List <Ship> ();
     eventShip       = null;
 }
Exemple #12
0
 void Start()
 {
     ship = (ShipyardModel.Ship)data[0];
     CompleteJourney();
 }