コード例 #1
0
 protected void AddChildren(State state, XmlNodeList childNodes)
 {
     foreach (XmlNode childList in childNodes)
     {
         if (childList.Name == "children")
         {
             foreach (XmlNode child in childList.ChildNodes)
             {
                 foreach (XmlAttribute attribute in child.Attributes)
                 {
                     if (attribute.Name.Equals("id"))
                     {
                         int value = StateIds.Index(attribute.Value);
                         if (value != StateIds.NONE)
                         {
                             state.AddChild(value);
                         }
                         break;
                     }
                 }
             }
             break;
         }
     }
 }
コード例 #2
0
 void Start()
 {
     text.text = StateIds.Name(ctrl.StateId);
     if (GameSessionManager.Instance.GetLevel() == -1)
     {
         buttonContinue.SetActive(false);
     }
 }
コード例 #3
0
    protected void LoadChildState(string childId)
    {
        State state = stateManager.GetState(StateId);

        if ((state.Children != null) && state.Children.Contains(StateIds.Index(childId)))
        {
            stateManager.SetState(StateIds.Index(childId));
        }
        else
        {
            throw new Exception("IStateController: 'LoadChildState' can only be called with one of its children state!");
        }
    }
コード例 #4
0
    public State[] LoadStateGraph()
    {
        TextAsset   xmlFile = (TextAsset)Resources.Load(filename, typeof(TextAsset));
        XmlDocument xmlDoc  = new XmlDocument();

        xmlDoc.LoadXml(xmlFile.text);
        XmlNodeList stateNodes = xmlDoc.GetElementsByTagName("state");

        // First parse to get names of states
        StateIds.Reset();
        foreach (XmlNode stateNode in stateNodes)
        {
            StateIds.Add(stateNode.Attributes["id"].Value);
        }

        State[] states = GetStates(stateNodes);

//TODO: check that all states have been allocated
//...

        return(states);
    }
コード例 #5
0
 protected virtual void GetAttributes(StateData data, XmlAttributeCollection attributes)
 {
     foreach (XmlAttribute attribute in attributes)
     {
         if (attribute.Name.Equals("id"))
         {
             data.id = StateIds.Index(attribute.Value);
         }
         else if (attribute.Name.Equals("scene"))
         {
             data.scene = attribute.Value;
         }
         else if (attribute.Name.Equals("next"))
         {
             data.next = StateIds.Index(attribute.Value);
         }
         else if (attribute.Name.Equals("restartable"))
         {
             data.restartable = ToBool(attribute.Value, data.restartable);
         }
     }
 }
コード例 #6
0
 void Start()
 {
     text.text = StateIds.Name(ctrl.StateId);
 }
コード例 #7
0
ファイル: Model.cs プロジェクト: msruzy/hydronumerics
 public void RunScenario()
 {
     RestoreState(StateIds.First());
     MoveInTime(SimulationEndTime, TimeStep);
 }
コード例 #8
0
    private void Update()
    {
        int number = 0;

        switch (currentStateId)                                                                                                                                                         //crate a switch statement that controls the states of the mole
        {
        case StateIds.hide:                                                                                                                                                             //the mole is currently underground
            System.Random rnd = new System.Random();
            yourCounter += Time.deltaTime;                                                                                                                                              //start a counter for the time
            number       = (int)yourCounter;
            List <int> relativePositions = new List <int>();
            float      characterX        = character.transform.position.x;
            float      characterZ        = character.transform.position.z;
            for (int i = 0; i < flowers.Length; i += 1)
            {
                float x           = flowers[i].transform.position.x;
                float z           = flowers[i].transform.position.z;
                float differenceX = x - characterX;
                float differenceZ = z - characterZ;

                if ((differenceX >= 80.0f || differenceX <= -80.0f) || (differenceZ >= 80.0f || differenceZ <= -80))                                                                    //this finds all the flowers that are at least acertain distance away from the player as a teleport candidate
                {
                    if (flowers[i].activeSelf)
                    {
                        relativePositions.Add(i);
                    }
                }
            }

            int randomLocation = rnd.Next(relativePositions.Count);                                                                                                                     //picks one of those valid flowers at random
            if (yourCounter >= 5.0f)                                                                                                                                                    //if youve been hidden for 5 seconds pop up at a random valid location, and reduce the amount of active flowers by 1
            {
                if (relativePositions.Count == 0)
                {
                    currentStateId = StateIds.hide;
                    break;
                }
                moleSplatPos = relativePositions[randomLocation];
                flowers[moleSplatPos].SetActive(false);
                transform.position = new Vector3(flowers[moleSplatPos].transform.position.x, 5, flowers[moleSplatPos].transform.position.z);

                if (flowers[moleSplatPos].GetComponent <flower>().flowerDestroyed == false)
                {
                    flowers[moleSplatPos].GetComponent <flower>().flowerDestroyed = true;
                    flowersRemaining -= 1;
                }



                currentStateId = StateIds.show;                                                                                                                                         //then set your state to show and reset the time counter
                yourCounter    = 0.0f;
            }



            break;                                                                                                                                                                      //end each state

        case StateIds.show:                                                                                                                                                             //the mole is currently above ground
            yourCounter += Time.deltaTime;
            number       = (int)yourCounter;
            if ((transform.position.z - character.transform.position.z) < 30.0f && (transform.position.z - character.transform.position.z) > -30.0f)
            {
                if ((transform.position.x - character.transform.position.x) < 30.0f && (transform.position.x - character.transform.position.x) > -30.0f)                                //if the character is within a certain distance teleport to safety, the counter will keep going in this case so
                {                                                                                                                                                                       //the state will be updated after less than 5 seconds anyway
                    transform.position = new Vector3(-1000, -50, -1000);
                }
            }

            if (yourCounter >= 5.0f)
            {
                transform.position = new Vector3(-1000, -50, -1000);                                                                                                                    //if the timer has reached 5 teleport the mole away and update the state to hide, and reset the time counter
                currentStateId     = StateIds.hide;
                yourCounter        = 0.0f;
            }

            double rz   = System.Convert.ToDouble(transform.position.z - avacado.transform.position.z);                                                                                 //check if the avacado is within a certain distance, if so, kill the mole. killing the mole is actually
            double rx   = System.Convert.ToDouble(transform.position.x - avacado.transform.position.x);                                                                                 //just teleporting it away and reducing the moles alive counter by 1, then changing the state to dead
            double pyth = (rx * rx) + (rz * rz);
            double q    = Math.Sqrt(pyth);
            q = (float)q;
            if (q < 20.0f && (avacado.transform.position.y < 20.0f && avacado.transform.position.y > -5.0f))
            {
                transform.position = new Vector3(-1000, -50, -1000);

                currentStateId  = StateIds.dead;
                molesRemaining -= 1;
            }
            break;

        case StateIds.dead:                                                                                                                                                             //the mole is currently dead
            yourCounter += Time.deltaTime;
            flowers[moleSplatPos].SetActive(true);
            flowers[moleSplatPos].transform.rotation = new Quaternion(0, 0, 0, 0);                                                                                                      //bring back the flower, and change its material to be the blood texture, then set it to be flat on the ground
            flowers[moleSplatPos].transform.position = new Vector3(flowers[moleSplatPos].transform.position.x, 0.1f, flowers[moleSplatPos].transform.position.z);                       //and set its scale to be 1:1:1
            flowers[moleSplatPos].GetComponent <Renderer>().material = deadMole;
            flowers[moleSplatPos].transform.localScale = new Vector3(1, 1, 1);

            if (yourCounter >= 5.0f)
            {
                transform.position = new Vector3(-1000, -50, -1000);                                                                                                                    //if hes been dead for 5 seconds then teleport him to the hide position, then reset the time counter and set the state back to hidden
                currentStateId     = StateIds.hide;
                yourCounter        = 0.0f;
            }
            break;
        }
    }
コード例 #9
0
 public HospitalizationData GetRecordsByDateAndState(DateTime date, StateIds stateId)
 {
     return(_records[stateId].Single(x => x.Date == date));
 }
コード例 #10
0
 public IEnumerable <HospitalizationData> GetStateRecordsByStateId(StateIds stateId, DateTime from)
 {
     _records.TryGetValue(stateId, out var records);
     return(records?.Where(x => x.Date >= from) ?? new HospitalizationData[] { });
 }
コード例 #11
0
ファイル: IState.cs プロジェクト: etiens/VikingQuest
 public override string ToString()
 {
     return(StateIds.Name(StateId));
 }