Пример #1
0
        void CalcMindshare()
        {
            float[] opTotals = new float[Constants.PlayerCount];
            //float grandTotal = 0.0f;

            // This double loop may look bad but the inner loop only executes 2-4 times
            foreach (GameObject gameObj in PeopleInRegion)
            {
                OpinionStatus opStat = gameObj.GetComponent <OpinionStatus>();
                for (int i = 0; i < opStat.Opinions.Length; i++)
                {
                    opTotals[i] += opStat.Opinions[i].Percent;
                    //grandTotal += opTotals[i];
                }
            }

            for (int i = 0; i < Constants.PlayerCount; i++)
            {
                //Debug.Log("Opinion " + i.ToString() + " has " + (opTotals[i] / people.Count).ToString() + "%, total is " + opTotals[i].ToString() + ", grand total is " + people.Count.ToString());

                CurrentMindshares[i] = (opTotals[i] / PeopleInRegion.Count);

                if ((opTotals[i] / PeopleInRegion.Count) >= DominantMindshareAtPercent)
                {
                    KingOfRegion = i;
                    if (this._capturable != null)
                    {
                        this._capturable.SetOwner(i);
                    }
                    this.gameObject.GetComponent <MeshRenderer>().material = regionSpawner.Materials[i];
                    break;
                }
            }
        }
Пример #2
0
        void VictoryMonitor()
        {
            float[] opTotals = new float[Constants.PlayerCount];
            //float grandTotal = 0.0f;

            // This double loop may look bad but the inner loop only executes 2-4 times
            foreach (GameObject gameObj in people)
            {
                OpinionStatus opStat = gameObj.GetComponent <OpinionStatus>();
                for (int i = 0; i < Constants.PlayerCount; i++)
                {
                    opTotals[i] += opStat.Opinions[i].Percent;
                    //grandTotal += opTotals[i];
                }
            }



            for (int i = 0; i < Constants.PlayerCount; i++)
            {
                //Debug.Log("Opinion " + i.ToString() + " has " + (opTotals[i] / people.Count).ToString() + "%, total is " + opTotals[i].ToString() + ", grand total is " + people.Count.ToString());

                CurrentMindshares[i] = (opTotals[i] / people.Count);

                if ((opTotals[i] / people.Count) >= VictoryTriggeredAtPercent)
                {
                    Victory = i;
                    break;
                }
            }
        }
Пример #3
0
        private void FixedUpdate()
        {
            this._timer += Time.deltaTime;

            foreach (GameObject person in this._affectedPeople)
            {
                OpinionStatus opinion = person.GetComponent <OpinionStatus>();
                opinion.AddToOpinion(this._owner, Time.deltaTime * 0.001f);
            }
        }
 // Use this for initialization
 void Start()
 {
     this._opinion = this.GetComponentInParent <OpinionStatus>();
     this._image   = this.GetComponent <UnityEngine.UI.Image>();
 }