Example #1
0
 private void Awake()
 {
     npcButtonsRef = transform.GetComponentInParent <NpcButtons>();
 }
Example #2
0
        private void Start()
        {
            /// Add ourself to list
            s_npcList.Add(this);

            /// Assign Values
            if (NPC.s_npcList.Count % 4 == 3)
            {
                myFeelings = new Feelings(0.2f, 0.2f);
            }
            else
            {
                myFeelings = new Feelings(1f, 1f);
            }

            Random.State oldState = Random.state;
            Random.InitState(name.Length);
            m_myHappinessDecay  = Random.Range(150, 250);
            m_myMotivationDecay = Random.Range(140, 240);
            //Debug.Log(name.Length + ": mhd->" + myHappinessDecay + " mmd->" + myMotivationDecay);
            Random.state = oldState;

            /// Get Components
            foreach (var item in GetComponentsInChildren <Slider>())
            {
                if (item.gameObject.name == "Happiness Slider")
                {
                    happySlider = item;
                }
                else if (item.gameObject.name == "Motivation Slider")
                {
                    motivationSlider = item;
                }
            }

            /// Add Components
            moveRef        = gameObject.AddComponent <DAS.NPCMovement>();
            m_modelChanger = gameObject.AddComponent <ModelChanger>();
            buttonRef      = gameObject.AddComponent <NpcButtons>();
            buttonRef.InitNpcButtons();
            buttonTogglerRef = gameObject.AddComponent <ButtonToggler>();
            buttonTogglerRef.InitButtonToggler();

            m_nameHolder = new GameObject("Name Holder");
            m_nameHolder.transform.parent = gameObject.transform;
            m_myNameDisplay = m_nameHolder.AddComponent <TextMesh>();

            /// Text
            if (m_myNameDisplay != null)
            {
                m_myNameDisplay.text                = name;
                m_myNameDisplay.alignment           = TextAlignment.Center;
                m_myNameDisplay.anchor              = TextAnchor.MiddleCenter;
                m_myNameDisplay.transform.position  = transform.position;
                m_myNameDisplay.transform.position += new Vector3(0, 3, 0);
                m_myNameDisplay.transform.forward   = Camera.main.transform.forward;
                m_myNameDisplay.transform.Rotate(0, 180, 0);
                m_myNameDisplay.characterSize = 0.03f;
                m_myNameDisplay.fontSize      = 155;
            }

            /// Material
            m_myMaterials         = GetComponentInChildren <MeshRenderer>().materials;
            m_moneyMaterial       = new Material(m_myMaterials[0]);
            m_moneyMaterial.color = Color.green;
        }