Example #1
0
 /// <summary>
 /// view model base is told which model objects to watch for changes
 /// when change happens, view for this view model will update all property bindings
 /// </summary>
 public MainViewModel(Main main, UpdateModelCommand updateModelCommand, ModelChanger modelChanger)
     : base(modelChanger, main)
 {
     this.main = main;
     this.updateModelCommand = updateModelCommand;
     this.UpdateCounterDetails();
 }
Example #2
0
 protected ViewModelBase(ModelChanger modelChanger, params object[] watchedModels)
 {
     this.ModelChanger = modelChanger;
     foreach (var watchedModel in watchedModels)
     {
         this.ModelChanger.SubscribeToModelChange(watchedModel, this.NotifyAllPropertyBindings);
     }
 }
Example #3
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;
        }
Example #4
0
 /// <summary>
 /// model command is explicitly told which objects will be changed
 /// when the model command is executed
 /// ---
 /// ninject singleton bindings will ensure these objects are the same
 /// as the objects used elsewhere in the domain model and view models
 /// </summary>
 public UpdateModelCommand(ModelChanger modelChanger, Main main)
     : base(modelChanger, main)
 {
     this.main = main;
 }
Example #5
0
 public BasicShellViewModel(MainViewModel mainViewModel, ModelChanger modelChanger)
     : base(modelChanger)
 {
     this.MainViewModel = mainViewModel;
 }
Example #6
0
 protected ModelCommand(ModelChanger modelChanger, params object[] changedModels)
 {
     this.modelChanger = modelChanger;
     this.changedModels = changedModels;
 }