예제 #1
0
    public void Save()
    {
       // Achievements.first.Value = true;
        BinaryFormatter bf = new BinaryFormatter();

        //create needed files
        FileStream file = File.Create(Application.persistentDataPath + "/PlayerInfo.dat");
        FileStream res = File.Create(Application.persistentDataPath + "/ResourceInfo.dat");

       // Get current resource numbers
        ResourceControl data = new ResourceControl();
        data.money = MoneyManager.money;
        data.water = MoneyManager.water;
        data.food = MoneyManager.food;
        data.power = MoneyManager.power;
        data.buildMat = MoneyManager.buildMat;
        data.rating = MoneyManager.rating;
        data.pop = MoneyManager.pop;
        data.conquered = MoneyManager.conquered;
        data.oxygen = MoneyManager.Oxygen;
        
        //serialize the information to the specified file
        bf.Serialize(file, ConvertObjects());
        bf.Serialize(res, data);

        //close the files and confirm save
        file.Close();
        res.Close();
        Debug.Log("Saved");
       
    }
예제 #2
0
        /* Events */
        private void setButtonEvents()
        {
            setTranslationEvents();

            DataBtnForward.Click += (o, e) =>
            {
                if (ResourceControl.DataEnd)
                {
                    showUIElements(EmailMeButton, MaskBox);
                    return;
                }
                ResourceControl.NextDataItem(this);
                DataBtnForward.Hide();
            };

            MaskBox.Click += (o, e) =>
            {
                init();
                ViewPresentation();
            };
            EmailMeButton.Click += (o, e) =>
            {
                var subject = (ResourceControl.Data.IsEnglish) ?
                              "Internship[C Sharp .Net]" :
                              "Stage[C Sharp .Net]";
                Process.Start(Uri.EscapeUriString($"mailto:[email protected]?Subject={subject}"));
            };
            DataNameButton.IsHitTestVisible = false;
            DataBtn.IsHitTestVisible        = false;
        }
예제 #3
0
 public static ResourceControl getInstance()
 {
     if (instance == null) {
         instance = new ResourceControl();
     }
     return instance;
 }
    // Start is called before the first frame update
    public void CreatePrize(Vector3 coordinates, int num)
    {
        ResourceControl rs = Instantiate(resPrefabs[num]);

        rs.transform.position = coordinates;
        rs.myCollider.enabled = true;
    }
예제 #5
0
        private ListView setListView <T>(ListView listView)
        {
            var data = ResourceControl.GetData <T>();
            var view = new GridView();

            foreach (var key in data.First().Keys)
            {
                var col = new GridViewColumn();
                col.Header = key;
                col.DisplayMemberBinding = new Binding($"[{key}]");
                view.Columns.Add(col);
            }
            listView.View        = view;
            listView.ItemsSource = data;
            return(listView);
        }
예제 #6
0
 public void SetResources()
 {
     ResourceControl.SetResources(CV);
     InitializeComponent();
     setButtonEvents();
     setCalendar();
     setTextBlock(this.FormationsTitle, "Training", "Formations");
     setTextBlock(AvailableBlock, "Available", "Disponible");
     setTextBlock(DurationBlock, "For 4 - 6 months", "Pendant 4 - 6 mois");
     setTextBlock(SpeedBlock, "Speed", "Vitesse");
     setTextBlock(ClickBlock, "Click Here", "Cliquez Ici");
     setTextBlock(SendMailBlock, "to send a mail to", "pour envoyer un mail à");
     setCheckBox(NeedBox, "Needs to find an internship", "Doit trouver une stage");
     DataContext = this;
     init();
 }
예제 #7
0
파일: JimAI.cs 프로젝트: B-Noone/Servare
    void Interact()
    {
        if (currentAction == action.Gather)
        {
            //Debug.Log("Gather");
            if (Objective.name == "StockpileBuilding")
            {
                //Debug.Log("Interact with Building");
                if (inventory == resourceSearch.Food)
                {
                    StockpileScript.food++;
                }
                else if (inventory == resourceSearch.Wood)
                {
                    StockpileScript.wood++;
                }
                else if (inventory == resourceSearch.Stone)
                {
                    StockpileScript.stone++;
                }
                inventory = resourceSearch.Nothing;
            }
            else
            {
                ResourceControl RCScript = Objective.GetComponent <ResourceControl>();
                if (RCScript != null)
                {
                    RCScript.numberOfResource -= 1;
                    if (Objective.name == "Bush")
                    {
                        inventory = resourceSearch.Food;
                    }
                    else if (Objective.name == "Tree")
                    {
                        inventory = resourceSearch.Wood;
                    }
                    else if (Objective.name == "Rock")
                    {
                        inventory = resourceSearch.Stone;
                    }
                }
            }

            ResetVars();
        }
        if (currentAction == action.Collect)
        {
            //Debug.Log("Collect");
            //Stockpile StockScript = Objective.GetComponent<Stockpile>();
            if (currentSearch == resourceSearch.Food && StockpileScript.food != 0)
            {
                StockpileScript.food -= 1;
                inventory             = resourceSearch.Food;
            }
            else if (currentSearch == resourceSearch.Wood && StockpileScript.wood != 0)
            {
                StockpileScript.wood -= 1;
                inventory             = resourceSearch.Wood;
            }
            else if (currentSearch == resourceSearch.Stone && StockpileScript.stone != 0)
            {
                StockpileScript.stone -= 1;
                inventory              = resourceSearch.Stone;
            }
        }
        if (currentAction == action.Build)
        {
            BuildingConstruct BuildScript = Objective.GetComponent <BuildingConstruct>();
            if (inventory == resourceSearch.Wood)
            {
                if (BuildScript.wood > 0)
                {
                    BuildScript.wood    -= 1;
                    inventory            = resourceSearch.Nothing;
                    BuildingToConstruct  = null;
                    BuildingRequirements = null;
                }
            }
            else if (inventory == resourceSearch.Stone)
            {
                if (BuildScript.stone > 0)
                {
                    BuildScript.stone   -= 1;
                    inventory            = resourceSearch.Nothing;
                    BuildingToConstruct  = null;
                    BuildingRequirements = null;
                }
            }
            else
            {
                currentAction = action.Collect;
            }
        }
        //Debug.Log("Reset Vars");
        //ResetVars();
    }
예제 #8
0
    public void OnPlanetTreasure()
    {
        if (gameObject.tag == "Planet")
        {
            List <float> probabs = possiblePrizes.GetProbabilitiesByLevel(currSceneLevel);
            //float prob = CSP.GetRandomFloat();
            float prob = 0.75f;
            ConstGameCtrl.PlanetSurprize prize = possiblePrizes.GetNameByProbability(currSceneLevel, prob);

            int prizeNum = (int)prize;
            Debug.Log("Prize num: " + prizeNum);

            if (prizeNum == 0) // Gold
            {
                ResourceControl RC = Instantiate(moneyPrefab);
                RC.SetParams("Money");
                RC.transform.SetParent(gameObject.transform);
                RC.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                RC.myCollider.enabled      = false;
                RC.StartMove(myRadii / 2);
            }

            if (prizeNum == 1) // Health
            {
                ResourceControl RC = Instantiate(healthPrefab);
                RC.SetParams("Health");
                RC.transform.SetParent(gameObject.transform);
                RC.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                RC.myCollider.enabled      = false;
                RC.StartMove(myRadii / 2);
            }

            if (prizeNum == 2) // Shield
            {
                ResourceControl RC = Instantiate(shieldPrefab);
                RC.SetParams("Shield");
                RC.transform.SetParent(gameObject.transform);
                RC.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                RC.myCollider.enabled      = false;
                RC.StartMove(myRadii / 2);
            }

            if (prizeNum == 3) // Fuel
            {
                ResourceControl RC = Instantiate(fuelPrefab);
                RC.SetParams("Fuel");
                RC.transform.SetParent(gameObject.transform);
                RC.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                RC.myCollider.enabled      = false;
                RC.StartMove(myRadii / 2);
            }

            if (prizeNum > 3) // Minerals
            {
                TresureControl TC = Instantiate(planetTreasurePrefab);
                TC.SetMineralParams(ConstGameCtrl.instance.GetPrizeParams(prizeNum - 4).prizeMaterial, ConstGameCtrl.instance.GetPrizeParams(prizeNum - 4).prizeMesh, ConstGameCtrl.instance.GetPrizeParams(prizeNum - 4).prizeName, System.Enum.GetName(typeof(ConstGameCtrl.PlanetSurprize), prizeNum));
                TC.transform.SetParent(gameObject.transform);
                TC.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
                TC.myCollider.enabled      = false;
                TC.StartMove(myRadii / 2);
            }
        }

        if (gameObject.tag == "Comet")
        {
            List <float> probabs = possiblePrizes.GetProbabilitiesByLevel(currSceneLevel);
            //float prob = CSP.GetRandomFloat();
            float prob = 0.95f;
            ConstGameCtrl.PlanetSurprize prize = possiblePrizes.GetNameByProbability(currSceneLevel, prob);

            int prizeNum = (int)prize;
            //Debug.Log("Prize num: " + prizeNum);

            ResourceControl RC;
            TresureControl  TC;

            if (prizeNum == 0) // Gold
            {
                RC = Instantiate(moneyPrefab);
                RC.SetParams("Money");
                RC.transform.position = gameObject.transform.position;
                RC.myCollider.enabled = true;
            }

            if (prizeNum == 1) // Health
            {
                RC = Instantiate(healthPrefab);
                RC.SetParams("Health");
                RC.transform.position = gameObject.transform.position;
                RC.myCollider.enabled = true;
            }

            if (prizeNum == 2) // Shield
            {
                RC = Instantiate(shieldPrefab);
                RC.SetParams("Shield");
                RC.transform.position = gameObject.transform.position;
                RC.myCollider.enabled = true;
            }

            if (prizeNum == 3) // Fuel
            {
                RC = Instantiate(fuelPrefab);
                RC.SetParams("Fuel");
                RC.transform.position = gameObject.transform.position;
                RC.myCollider.enabled = true;
            }

            if (prizeNum > 3) // Minerals
            {
                TC = Instantiate(planetTreasurePrefab);
                TC.SetMineralParams(ConstGameCtrl.instance.GetPrizeParams(prizeNum - 4).prizeMaterial, ConstGameCtrl.instance.GetPrizeParams(prizeNum - 4).prizeMesh, ConstGameCtrl.instance.GetPrizeParams(prizeNum - 4).prizeName, System.Enum.GetName(typeof(ConstGameCtrl.PlanetSurprize), prizeNum));
                TC.transform.position = gameObject.transform.position;
                TC.myCollider.enabled = true;
            }

            Collider myColl = GetComponent <Collider>();
            myColl.enabled = false;

            Invoke("OnRealDeath", 3f);
            cometTail.Stop();
            anim.SetTrigger("OnDeath");
            cometExplode.Play();
        }
    }