Exemplo n.º 1
0
 //find positions of all items on screen
 void CreateRects()
 {
     m_PopupItems = new List <popupItem>();
     for (int i = 0; i < CurrentPage.Layout.transform.childCount; i++)
     {
         ResearchItem itemOnScreen = ((ResearchItem)CurrentPage.Layout.transform.GetChild(i).GetComponent("ResearchItem"));
         if (itemOnScreen != null && itemOnScreen.Enabled())
         {
             popupItem item;
             item.area = CurrentPage.Layout.transform.GetChild(i).Find("Placeholder").GetComponent <GUIBase_Sprite>().Widget.GetRectInScreenCoords();
             if (itemOnScreen.weaponID != E_WeaponID.None)
             {
                 item.item = new ShopItemId((int)itemOnScreen.weaponID, GuiShop.E_ItemType.Weapon);
                 m_PopupItems.Add(item);
             }
             else if (itemOnScreen.upgradeID != E_UpgradeID.None)
             {
                 item.item = new ShopItemId((int)itemOnScreen.upgradeID, GuiShop.E_ItemType.Upgrade);
                 m_PopupItems.Add(item);
             }
             else if (itemOnScreen.perkID != E_PerkID.None)
             {
                 item.item = new ShopItemId((int)itemOnScreen.perkID, GuiShop.E_ItemType.Perk);
                 m_PopupItems.Add(item);
             }
             else if (itemOnScreen.itemID != E_ItemID.None)
             {
                 item.item = new ShopItemId((int)itemOnScreen.itemID, GuiShop.E_ItemType.Item);
                 m_PopupItems.Add(item);
             }
         }
     }
 }
Exemplo n.º 2
0
 public ResearchTreeNode(ResearchItem item)
 {
     this.researchName = item.researchName;
     this.xpCost       = item.xpCost;
     this.researched   = item.researched;
     this.item         = item;
 }
        // POST /api/projects/4/researchItems
        public virtual HttpResponseMessage Post(int projectId, ResearchItem researchItem)
        {
            try {
                // Make sure it is being inserted to a project owned by the user.
                var project = _projectRepository.GetByUser(projectId, User.Identity.Name);
                if (project == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Project not found for user " + User.Identity.Name + "."));
                }
                researchItem.ProjectId   = projectId;
                researchItem.UserName    = User.Identity.Name;
                researchItem.DateCreated = DateTime.Now;
                researchItem.DateUpdated = DateTime.Now;
                _researchItemRepository.Insert(researchItem);
                _researchItemRepository.Commit();
            } catch (Exception ex) {
                var error = new HttpError("Error inserting research item: " + ex.Message)
                {
                    { "Trace", ex.StackTrace }
                };
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, error));
            }
            var    response = Request.CreateResponse(HttpStatusCode.Created, researchItem);
            string uri      = Url.Link("ProjectResearchItemsApi", new { projectId = projectId, researchItemId = researchItem.ResearchItemId });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //查看详情
            if (!IsPostBack)
            {
                if (Request.QueryString["power"] != null)
                {
                    Panel1.Visible = false;
                }
                else
                {
                    Panel1.Visible = true;
                }

                int id       = Convert.ToInt32(Request.QueryString["id"].ToString());
                int personId = Convert.ToInt32(Session["PersonId"]);
                var Item     = DB.ResearchItem.FirstOrDefault(a => a.Id == id); //获取对象
                PageModel   = Item;
                Label1.Text = Item.Id.ToString();                               //记录项目Id

                //绑定参与人员
                List <Person> personList = DB.Person.Where(a => true && a.Id != personId).ToList();
                foreach (var item in personList)
                {
                    ListItem listItem = new ListItem();
                    listItem.Text  = item.Name;
                    listItem.Value = item.Id.ToString();
                    DropDownList1.Items.Add(listItem);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Panel1.Visible = false;
            Panel2.Visible = true;
            if (!IsPostBack)
            {
                if (Request.QueryString["type"] != null)
                {
                    //编号
                    int id   = Convert.ToInt32(Request.QueryString["id"].ToString());
                    var Item = DB.ResearchItem.FirstOrDefault(a => a.Id == id);//获取对象
                    PageModel        = Item;
                    ItemName.Text    = Item.ItemName;
                    ItemType.Text    = Item.ItemType;
                    ItemCompany.Text = Item.ItemCompany;
                    MajorPerson.Text = Item.MajorPerson;
                    Tel.Text         = Item.Tel;
                    Funds.Text       = Item.Funds.ToString();
                    ExeYear.Text     = Item.ExeYear.ToString();
                    Label1.Text      = Item.FileName;

                    Panel1.Visible = true;
                    Panel2.Visible = false;
                }
            }
        }
Exemplo n.º 6
0
        // USERGUIDEACTION INTERFACE

        protected override bool OnExecute()
        {
            if (base.OnExecute() == false)
            {
                return(false);
            }

            E_WeaponID  weaponID  = ItemType == GuiShop.E_ItemType.Weapon ? (E_WeaponID)ItemId : E_WeaponID.None;
            E_ItemID    itemID    = ItemType == GuiShop.E_ItemType.Item ? (E_ItemID)ItemId : E_ItemID.None;
            E_UpgradeID upgradeID = ItemType == GuiShop.E_ItemType.Upgrade ? (E_UpgradeID)ItemId : E_UpgradeID.None;
            E_PerkID    perkID    = ItemType == GuiShop.E_ItemType.Perk ? (E_PerkID)ItemId : E_PerkID.None;

            ResearchItem[] items = ResearchSupport.Instance.GetItems();

            foreach (var item in items)
            {
                if (item.weaponID == weaponID && weaponID != E_WeaponID.None ||
                    item.itemID == itemID && itemID != E_ItemID.None ||
                    item.upgradeID == upgradeID && upgradeID != E_UpgradeID.None ||
                    item.perkID == perkID && perkID != E_PerkID.None)
                {
                    Item = item;
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 7
0
 public void FinishResearch(ResearchItem researchItem)
 {
     unlockedResearch.Remove(researchItem);
     doneResearch.Add(researchItem);
     currentResearch = null;
     uiHandler.ShowPopup();
 }
Exemplo n.º 8
0
 void RemoveResearch(ResearchItem removeItem)
 {
     if (_research.Count > 0)
     {
         _research.Remove(removeItem);
         //patents.Remove(removeItem);
     }
 }
Exemplo n.º 9
0
 void AddResearch(ResearchItem newItem)
 {
     if (_research.Count < 3)
     {
         _research.Add(newItem);
         //patents.Add(newItem, 0);
     }
 }
Exemplo n.º 10
0
 void SellPatent(ResearchItem productSold)
 {
     //if (patents[productSold] > 0)
     //{
     //	//patents[productSold]--;
     //	BusinessManager.businessManager.totalMoney += productSold.sellsFor;
     //}
     //Debug.Log("Sell " + productSold.name + " at " + this.name);
 }
Exemplo n.º 11
0
    ItemSettings GetItem(ResearchItem item)
    {
        if (item.itemID != E_ItemID.None)
        {
            return(ItemSettingsManager.Instance.Get(item.itemID));
        }

        return(null);
    }
Exemplo n.º 12
0
    public static void CreateNewResearch()
    {
        ResearchItem asset = (ResearchItem)CreateAsset("DoVAlpha/GovernmentsDefault/data/research/", typeof(ResearchItem));

        if (asset != null)
        {
            asset.ResearchName = "a name";
        }
    }
Exemplo n.º 13
0
    public void AddNewResearchToList(GameObject addTo, ResearchItem rs)
    {
        var researchItem = new GameObject(string.Format("{0}_Ingame", rs.ResearchName));
        var newData      = researchItem.AddComponent <ResearchProjectInfo>();

        newData.ResearchItem.IsResearchKnownToPlayer = true;
        newData.ResearchItem = rs;
        newData.Set(this);
        researchItem.transform.SetParent(addTo.transform);
    }
Exemplo n.º 14
0
        //实验记录
        private void PageLoad()
        {
            //查看所有记录
            int id   = Convert.ToInt32(Request.QueryString["id"].ToString());
            var list = DB.ExpRecord.Where(a => a.ItemId == id).ToList();

            GvData.DataSource = list;
            GvData.DataBind();

            PageModel = DB.ResearchItem.FirstOrDefault(a => a.Id == id);//获取项目对象
        }
Exemplo n.º 15
0
	public void selectKid(ResearchItem aItem,UISprite aSprite) {
		deselectAllKids();
		if(aItem!=null) {
			aItem.select();
			blackFadeForIndividualResearch.gameObject.SetActive(true);
			individualResearch.initResearch(aItem.researchRow,this.carRef,aSprite);
			individualResearch.toggleConversation();
			CarDetails cd = InterfaceMainButtons.REF.createCarDetailsScreen(this.gameObject,this.carRef,false);
			cd.alignToLeft();
			cd.showEffectOfResearch(aItem);
		}
	}
Exemplo n.º 16
0
        public static void ModifyFutureUnitsWithResearch(Type unitType, ResearchItem research)
        {
            IUnitFactory factory;

            if (Factories.TryGetValue(unitType, out factory))
            {
                factory.AddResearchUpgrade(research);
            }
            else
            {
                throw new Exception("Invalid unit type");
            }
        }
Exemplo n.º 17
0
    bool CanOffer(ResearchItem item)
    {
        if (item.weaponID != E_WeaponID.None)
        {
            return(true);
        }
        else if (item.itemID != E_ItemID.None)
        {
            return(true);
        }

        return(false);
    }
Exemplo n.º 18
0
    string GetId(ResearchItem item)
    {
        if (item.weaponID != E_WeaponID.None)
        {
            return(item.weaponID.ToString());
        }
        else if (item.itemID != E_ItemID.None)
        {
            return(item.itemID.ToString());
        }

        return(null);
    }
Exemplo n.º 19
0
        static bool Prefix(Panel_FireStart __instance, Campfire ___m_CampFireInstance, FireStarterItem ___m_KeroseneAccelerant, FireManager ___m_FireManager, bool skipResearchItemCheck = false)
        {
            var traverseInstance = Traverse.Create(__instance);

            traverseInstance.Field("m_FireManager").SetValue(GameManager.GetFireManagerComponent());

            var selectedFireStarter = traverseInstance.Method("GetSelectedFireStarter").GetValue <FireStarterItem>();
            var selectedTinder      = traverseInstance.Method("GetSelectedTinder").GetValue <FuelSourceItem>();
            var selectedFuelSource  = traverseInstance.Method("GetSelectedFuelSource").GetValue <FuelSourceItem>();
            var selectedAccelerant  = traverseInstance.Method("GetSelectedAccelerant").GetValue <FireStarterItem>();

            if (___m_CampFireInstance && ___m_CampFireInstance.TooWindyToStart())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Itstoowindytostartafirethere"), false);
                return(false);
            }
            if (selectedFireStarter == null || (GameManager.GetSkillFireStarting().TinderRequired() && selectedTinder == null) || selectedFuelSource == null)
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Insufficientmaterialstocreatefire"), false);
                return(false);
            }

            if (selectedFireStarter.m_RequiresSunLight && !traverseInstance.Method("HasDirectSunlight").GetValue <bool>())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Magnifyinglensrequiresdirectsunlight"), false);
                return(false);
            }
            if (!skipResearchItemCheck)
            {
                ResearchItem component = selectedFuelSource.GetComponent <ResearchItem>();
                if (component != null && !component.IsResearchComplete())
                {
                    Panel_Confirmation.CallbackDelegate forceBurnResearchItem = () => traverseInstance.Method("ForceBurnResearchItem").GetValue();
                    InterfaceManager.m_Panel_Confirmation.ShowBurnResearchNotification(forceBurnResearchItem);
                    return(false);
                }
            }
            if (selectedAccelerant != null && selectedAccelerant == ___m_KeroseneAccelerant)
            {
                GameManager.GetPlayerManagerComponent().DeductLiquidFromInventory(GameManager.GetFireManagerComponent().m_KeroseneLitersAccelerant, GearLiquidTypeEnum.Kerosene);
            }
            float percentChanceSuccess = TinderHelper.CalculateFireStartSuccess(selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant);

            ___m_FireManager.PlayerStartFire(___m_CampFireInstance, selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant, percentChanceSuccess);
            __instance.Enable(false);
            GameAudioManager.PlayGuiConfirm();
            return(false);
        }
Exemplo n.º 20
0
    // ------
    public void SetParent(ResearchItem parent)
    {
        if (m_Parent)
        {
            Error("Parent already assigned!");
        }
        m_Parent = parent;

        foreach (ResearchItem item in children)
        {
            if (item && (item == m_Parent))
            {
                Error("Cyclic parentship!");
            }
        }
    }
Exemplo n.º 21
0
        internal static void Configure(ModComponent modComponent)
        {
            ModResearchComponent modResearch = modComponent.TryCast <ModResearchComponent>();

            if (modResearch is null)
            {
                return;
            }

            ResearchItem researchItem = ModComponentUtils.ComponentUtils.GetOrCreateComponent <ResearchItem>(modResearch);

            researchItem.m_ReadAudio             = modResearch.ReadAudio;
            researchItem.m_SkillPoints           = modResearch.SkillPoints;
            researchItem.m_NoBenefitAtSkillLevel = modResearch.NoBenefitAtSkillLevel;
            researchItem.m_SkillType             = ModComponentUtils.EnumUtils.TranslateEnumValue <SkillType, ModComponentAPI.SkillType>(modResearch.SkillType);
            researchItem.m_TimeRequirementHours  = modResearch.TimeRequirementHours;
        }
        public void Put_ResearchItem_Returns_Expected_Header_For_James(string version)
        {
            //Setup
            _projectRepository      = _mockRepositories.GetProjectsRepository(ReturnType.Normal);
            _researchItemRepository = _mockRepositories.GetResearchItemsRepository(ReturnType.Normal);
            var researchItemsController = SetupController(_researchItemRepository.Object, _projectRepository.Object, "james", HttpMethod.Put, version);
            var inputResearchItem       = new ResearchItem()
            {
                ResearchItemId = 1, ProjectId = 1, Subject = "Update Test 1", UserName = "******", Description = "Insert Test Description"
            };

            //Act
            var response = researchItemsController.Put(1, 1, inputResearchItem);

            //Assert
            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "Expecting an OK Status Code");
            Assert.AreEqual("http://localhost/api/projects/1/researchItems/1", response.Headers.Location.ToString());
        }
        public void Put_ResearchItem_Database_Exception_Returns_Error(string version)
        {
            //Setup
            _projectRepository      = _mockRepositories.GetProjectsRepository(ReturnType.Normal);
            _researchItemRepository = _mockRepositories.GetResearchItemsRepository(ReturnType.Exception);
            var researchItemsController = SetupController(_researchItemRepository.Object, _projectRepository.Object, "james", HttpMethod.Put, version);
            var inputResearchItem       = new ResearchItem()
            {
                ResearchItemId = 1, ProjectId = 1, Subject = "Update Test 1", UserName = "******", Description = "Insert Test Description"
            };

            //Act
            var     response     = researchItemsController.Put(1, 1, inputResearchItem);
            dynamic errorMessage = JObject.Parse(response.Content.ReadAsStringAsync().Result);

            //Assert
            Assert.AreEqual(HttpStatusCode.InternalServerError, response.StatusCode, "Expecting an Internal Server Error Status Code");
            Assert.AreEqual("Error updating research item: Database exception!", (string)errorMessage.Message);
        }
        public void Put_James_ResearchItem_Returns_Null_ResearchItem_For_John(string version)
        {
            //Setup
            _projectRepository      = _mockRepositories.GetProjectsRepository(ReturnType.Normal);
            _researchItemRepository = _mockRepositories.GetResearchItemsRepository(ReturnType.Normal);
            var researchItemsController = SetupController(_researchItemRepository.Object, _projectRepository.Object, "john", HttpMethod.Put, version);
            var inputResearchItem       = new ResearchItem()
            {
                ResearchItemId = 1, ProjectId = 3, Subject = "Update Test 1", UserName = "******", Description = "Insert Test Description"
            };

            //Act
            var     response     = researchItemsController.Put(3, 1, inputResearchItem);
            dynamic errorMessage = JObject.Parse(response.Content.ReadAsStringAsync().Result);

            //Assert
            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode, "Expecting a Not Found Status Code");
            Assert.AreEqual("Research item not found for user john.", (string)errorMessage.Message);
        }
Exemplo n.º 25
0
    // -----
    public void AddAllConnectedItemGUIDs(ResearchItem item, List <int> insertAllItemsHere)
    {
        int upgrades = item.GetNumOfUpgrades();

        if (upgrades > 0)
        {
            for (int i = 0; i < upgrades; i++)
            {
                if (item.OwnsUpgrade(i))
                {
                    insertAllItemsHere.Add(item.GetUpgrade(i).GetGUID());
                }
            }
        }
        if (!item.IsDefault())
        {
            insertAllItemsHere.Add(item.GetGUID());
        }
        //Debug.Log("Added: "+TextDatabase.instance[item.GetName()]);
    }
Exemplo n.º 26
0
    int GetUsedTimes(ResearchItem item, PlayerPersistantInfo ppi, RoundFinalResult results)
    {
        int result = 0;

        if (item.weaponID != E_WeaponID.None)
        {
            PPIWeaponData temp = ppi.InventoryList.Weapons.Find(obj => obj.ID == item.weaponID);
            if (temp.ID != E_WeaponID.None)
            {
                result = temp.StatsFire;
            }
        }
        else if (item.itemID != E_ItemID.None)
        {
            PPIItemData temp = ppi.InventoryList.Items.Find(obj => obj.ID == item.itemID);
            if (temp.ID != E_ItemID.None)
            {
                result = temp.StatsUseCount;
            }
        }

        return(result);
    }
        // PUT /api/projects/4/researchitems/5
        public virtual HttpResponseMessage Put(int projectId, int researchItemId, ResearchItem researchItem)
        {
            var          project             = new Project();
            ResearchItem currentResearchItem = null;

            try
            {
                project = _projectRepository.GetByUser(projectId, User.Identity.Name);
                if (project == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Project not found for user " + User.Identity.Name + "."));
                }
                currentResearchItem = _researchItemRepository.GetByUser(researchItemId, User.Identity.Name);
                if (currentResearchItem == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Research item not found for user " + User.Identity.Name + "."));
                }
                currentResearchItem.DateUpdated = DateTime.Now;
                currentResearchItem.Subject     = researchItem.Subject;
                currentResearchItem.Description = researchItem.Description;
                _researchItemRepository.Commit();
            }
            catch (Exception ex)
            {
                var error = new HttpError("Error updating research item: " + ex.Message)
                {
                    { "Trace", ex.StackTrace }
                };
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, error));
            }

            var    response = Request.CreateResponse(HttpStatusCode.OK, currentResearchItem);
            string uri      = Url.Link("ProjectResearchItemsApi", new { projectId = projectId, researchItemId = researchItem.ResearchItemId });

            response.Headers.Location = new Uri(uri);
            return(response);
        }
Exemplo n.º 28
0
    List <WeaponSettings.Upgrade> CollectUpgrades(ResearchItem item, int money)
    {
        List <WeaponSettings.Upgrade> result = new List <WeaponSettings.Upgrade>();

        int count = item.GetNumOfUpgrades();

        for (int idx = 0; idx < count; ++idx)
        {
            if (item.OwnsUpgrade(idx) == true)
            {
                continue;
            }

            WeaponSettings.Upgrade upgrade = item.GetUpgrade(idx);
            if (upgrade.MoneyCost > money)
            {
                continue;
            }

            result.Add(upgrade);
        }

        return(result);
    }
Exemplo n.º 29
0
	public void showEffectOfResearch(ResearchItem aResearch) {
		if(aResearch.researchRow._effectonhp>0f) {
			this.horsepowerBoost.color = Color.green;
			this.horsepowerBoost.text = "+"+aResearch.researchRow._effectonhp;
			this.horsepowerBoost.gameObject.SetActive(true);
		}
		if(aResearch.researchRow._effectontorque>0f) {
			this.torqueBoost.color = Color.green;
			this.torqueBoost.text = "+"+aResearch.researchRow._effectontorque;
			this.torqueBoost.gameObject.SetActive(true);
		}
		if(aResearch.researchRow._effectonturbopsi>0f) {
			this.turboBoost.color = Color.green;
			this.turboBoost.text = "+"+aResearch.researchRow._effectonturbopsi;
			this.turboBoost.gameObject.SetActive(true);
		}
		if(aResearch.researchRow._effectonnitrocapacity>0f) {
			this.nitroBoost.color = Color.green;
			this.nitroBoost.text = "+"+aResearch.researchRow._effectonnitrocapacity;
			this.nitroBoost.gameObject.SetActive(true);
		}
		
		if(aResearch.researchRow._effectonshiftspeed<0f) {
			this.shiftspeedBoost.color = Color.green;
			this.shiftspeedBoost.text = "+"+aResearch.researchRow._effectonshiftspeed;
			this.shiftspeedBoost.gameObject.SetActive(true);
		}
		if(aResearch.researchRow._bodyaerodragreduce<0f) {
			this.dragBoost.color = Color.green;
			this.dragBoost.text = "+"+aResearch.researchRow._bodyaerodragreduce;
			this.dragBoost.gameObject.SetActive(true);
		}
		if(aResearch.researchRow._percentofdrswingtoremove>0f) {
			this.hasDRSValue.color = Color.green;
			this.hasDRSValue.text = "+ 1 Level";
			this.hasDRSValue.gameObject.SetActive(true);
		}
		if(aResearch.researchRow._maxspeedadd>0f) {
			this.maxSpeedBoost.color = Color.green;
			this.maxSpeedBoost.text = "+"+aResearch.researchRow._maxspeedadd;
			this.maxSpeedBoost.gameObject.SetActive(true);
		}
		
	}
Exemplo n.º 30
0
 public void BeginResearch(ResearchItem researchItem)
 {
     currentResearch = researchItem;
 }
 public void AddResearchUpgrade(ResearchItem research)
 {
     Researches.Add(research);
 }
Exemplo n.º 32
0
 void SwitchResearch(ResearchItem itemSwitch)
 {
     int branchIndex = itemSwitch.transform.parent.GetSiblingIndex();
     ResearchItem prevItem = branchActive[branchIndex];
     if(prevItem){
         prevItem.beingResearched = false;
     }
     itemSwitch.beingResearched = true;
     branchActive[branchIndex] = itemSwitch;
     ClosePopup();
     CreatePopup(lastPopupIndex);
     UpdateUINodes();
 }
Exemplo n.º 33
0
        public void Save(string filename, SavFile file)
        {
            using (FileStream fsout = new FileStream(filename, FileMode.Create, FileAccess.Write))
            {
                using (BinaryWriter brout = new BinaryWriter(fsout))
                {
                    brout.Write(Common.WriteStruct(file.Header));

                    brout.Write((short)file.ResearchItems.Count);
                    for (int i = 0; i < file.ResearchItems.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.ResearchItems[i]));
                    }

                    for (int i = 0; i < 34; i++)
                    {
                        var t = new ResearchItem();
                        t.RequiredBy    = new ResearchableItem[5];
                        t.RequiredBy[0] = ResearchableItem.End;
                        brout.Write(Common.WriteStruct(t));
                    }

                    for (int i = 0; i < 7; i++)
                    {
                        brout.Write(file.CurrentResearchItems[i]);
                    }

                    brout.Write(file.Unknown1);
                    brout.Write(file.Unknown2);
                    brout.Write((int)file.ResearchManagementType);
                    brout.Write(file.Unknown3);

                    brout.Write(file.StarSystems.Count);
                    for (int i = 0; i < file.StarSystems.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.StarSystems[i]));
                    }

                    brout.Write(file.PlanetStructures.Count);
                    for (int i = 0; i < file.PlanetStructures.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.PlanetStructures[i]));
                    }

                    brout.Write((short)file.Planets.Count);
                    for (int i = 0; i < file.Planets.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.Planets[i]));
                    }

                    brout.Write(file.Unknown4);

                    brout.Write((short)file.Ships.Count);
                    for (int i = 0; i < file.Ships.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.Ships[i]));
                    }

                    brout.Write(file.Unknown5);

                    brout.Write((short)file.Diplomacies.Count);
                    for (int i = 0; i < file.Diplomacies.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.Diplomacies[i]));
                    }

                    brout.Write(file.Unknown6);

                    brout.Write(file.StarLanes.Count);
                    for (int i = 0; i < file.StarLanes.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.StarLanes[i]));
                    }

                    for (int i = 0; i < file.StarSystems.Count; i++)
                    {
                        brout.Write(Common.WriteStruct(file.StarLaneCounts[i]));
                    }

                    var t2 = new byte[100];
                    for (int i = 0; i < 100; i++)
                    {
                        t2[i] = 0xff;
                    }
                    for (int i = 0; i < 100 - file.StarSystems.Count; i++)
                    {
                        //TODO: Blank starlanecount structs should all be 0xff
                        //brout.Write(WriteStruct(new StarLaneCount()));
                        brout.Write(t2);
                    }

                    brout.Write(file.Unknown7);
                }
            }
        }
Exemplo n.º 34
0
    public void CreatePopup(int nodeIndex)
    {
        popup.SetActive(true);
        lastPopupIndex = nodeIndex;
        if(popupBar)
            Destroy(popupBar.transform.parent.gameObject);
        popupItem = nodeList.ElementAt(nodeIndex);
        GameObject nodeInst = GameObject.Instantiate(treeParent.parent.Find("NodeT").gameObject);
        Vector3 tScale = treeParent.parent.Find("NodeT").localScale;
        popupBar = nodeInst.transform.Find("ProgBar").GetComponent<Image>();
        nodeInst.transform.SetParent(popup.transform.Find("NodeClone"));
        nodeInst.transform.localPosition = Vector3.zero;
        nodeInst.transform.localScale = tScale;
        float halfScreen = (float)Screen.width / 2f;
        float fourthScreen = (float)Screen.width / 4f;
        int branchIndex = popupItem.transform.parent.GetSiblingIndex();
        if(popupItem.transform.position.x > halfScreen)
            popup.transform.position = new Vector3(halfScreen - fourthScreen, popup.transform.position.y, 0f);
        else
            popup.transform.position = new Vector3(halfScreen + fourthScreen, popup.transform.position.y, 0f);
        angOff = Quaternion.Euler(new Vector3(0f, 0f, branchIndex * 120f));

        Button popButt = popup.transform.Find("Button").GetComponent<Button>();
        Text popButtText = popup.transform.Find("Button/Text").GetComponent<Text>();

        if(popupItem.transform.Find("Icon").GetComponent<Image>().sprite.name != "Unknown"){
            popup.transform.Find("PopupTitle").GetComponent<Text>().text = popupItem.dispName;
            popup.transform.Find("PopupQuote").GetComponent<Text>().text = "''" + popupItem.quote + "''";

            Image popIcon = nodeInst.transform.Find("Icon").GetComponent<Image>();
            popIcon.sprite = Resources.Load<Sprite> ("SciTreeIcons/" + popupItem.name);
            popIcon.color = popupItem.displayColor;

            if(popupItem.researched){
                popup.transform.Find("PopupTime").GetComponent<Text>().text = "Done.";
                popButtText.text = "Researched";
                popButt.interactable = false;
                return;
            }

            int completeTime = (int)(((popupItem.researchRequired - popupItem.researchProgress)/deltaResearchBranches[branchIndex]) / GM.ticks);

            if(popupItem.beingResearched){
                popButtText.text = "Researching...";
                popButt.interactable = false;
            }else{
                popButtText.text = "Research";
                popButt.interactable = true;
                popButt.onClick.RemoveAllListeners();
                popButt.onClick.AddListener(delegate {
                    SwitchResearch(popupItem);
                });
            }
        }else{
            string ttitle = CensorString(popupItem.dispName);
            string tquote = CensorString(popupItem.quote);
            popup.transform.Find("PopupTitle").GetComponent<Text>().text = ttitle;
            popup.transform.Find("PopupTime").GetComponent<Text>().text = "???? ?? ?? ???";
            popup.transform.Find("PopupQuote").GetComponent<Text>().text = tquote;

            Image popIcon = nodeInst.transform.Find("Icon").GetComponent<Image>();
            popIcon.sprite = Resources.Load<Sprite> ("SciTreeIcons/Unknown");
            popIcon.color = popupItem.displayColor;
            popButtText.text = "?????????";
            popButt.interactable = false;
        }
    }