예제 #1
0
    void UpdateState()
    {
        m_Anim.ResetTrigger(m_State.ToString());

        switch (m_State)
        {
        case state.stand:
            if (m_FIndAttack.m_Player)
            {
                if (m_Time > m_TimeAttack)
                {
                    m_Time  = 0;
                    m_State = state.attack;
                }
                break;
            }
            if (m_Find.m_Player)
            {
                m_State = state.run;
            }
            break;

        case state.run:
            if (m_FIndAttack.m_Player)
            {
                if (m_Time > m_TimeAttack)
                {
                    m_Time  = 0;
                    m_State = state.attack;
                    break;
                }
                m_State = state.stand;
                break;
            }

            if (!m_Find.m_Player)
            {
                m_State = state.stand;
            }
            break;

        case state.attack:
            if (m_Time > 0.5f)
            {
                if (!m_FIndAttack.m_Player && m_Find.m_Player)
                {
                    m_State = state.run;
                    break;
                }
                m_State = state.stand;
            }
            break;

        default: break;
        }

        m_Anim.SetTrigger(m_State.ToString());
    }
예제 #2
0
    void FriendlyIdle()
    {
        previousState = aiState.ToString();

        ai.canMove = false;
        if (Vector3.Distance(transform.position, ai.target.position) > distanceFromTarget && aiVision.canSeePlayer == false)
        {
            aiState = state.following;
        }
    }
예제 #3
0
    public static void PlayerConnected()
    {
        print(myState.ToString());

        if (myState == state.noPlayers)
        {
            myState = state.onePlayer;
        }
        else
        {
            myState = state.readyToGo;
        }

        print(myState.ToString());
    }
예제 #4
0
 // Update is called once per frame
 void Update()
 {
     stats();
     hungerJauge.value = 100 - hunger;
     thirstJauge.value = 100 - thirst;
     stateDisplay.text = currentState.ToString();
 }
예제 #5
0
    void Awake()
    {
        this.a  = this.GetComponent <Animator>();
        this.sr = this.GetComponent <SpriteRenderer>();

        this.a.Play(default_state.ToString());
    }
예제 #6
0
파일: FSM.cs 프로젝트: GenKlim/Laboratory
        public string func(string s)
        {
            string w = "";

            for (int i = 0; i < s.Length; i++)
            {
                w += "f(" + activeState.ToString() + " , " + s[i].ToString() + ") = ";
                setState(s[i]);
                w += activeState.ToString() + Environment.NewLine;
                if (activeState == state.Error)
                {
                    break;
                }
            }
            return(w);
        }
 public void statesSwich(string str)
 {
     setPos = false;
     if (str == "move")
     {
         Stat = state.move;
     }
     if (str == "rotate")
     {
         Stat = state.rotation;
     }
     if (str == "setpoint")
     {
         Stat   = state.setpoint;
         setPos = true;
     }
     if (str == "inside")
     {
         Stat    = state.inside;
         _inside = true;
     }
     if (str == "scale")
     {
         Stat = state.scale;
     }
     if (str == "inside")
     {
         Stat = state.inside;
     }
     text.text = Stat.ToString();
 }
예제 #8
0
 void changeAnimation()
 {
     if (lastState != currentState)
     {
         animator.SetTrigger(currentState.ToString());
     }
 }
예제 #9
0
 IEnumerator AIFSM()
 {
     while (true)
     {
         yield return(StartCoroutine(currentState.ToString()));
     }
 }
예제 #10
0
    public void ChangeState(state newState)
    {
        if (newState == ActuaState)
        {
            return;
        }

        ActuaState = newState;
        Debug.Log(ActuaState.ToString());
    }
    public void ChangeState(state newState)
    {
        if (newState == currentState)
        {
            return;
        }

        currentState = newState;
        Debug.Log(currentState.ToString());
    }
 // Update is called once per frame
 void Update()
 {
     if (quantParaVoltar == quant)
     {
         Invoke(recompensa.ToString(), 0);
         trocaScene.SetActive(true);
         //aux = Instantiate(trocaScene, posParaVoltar.transform.position, Quaternion.identity) as GameObject;
         // aux.GetComponent<trocascene>().saida = 999;
         //aux.GetComponent<trocascene>().scene = nomeDaVolta;
         quantParaVoltar = 0;
     }
 }
예제 #13
0
    /*
     * ChangeState: método encargado de cambiar el estado del agente por
     * otro de los definidos en la máquina de estados.
     */
    protected virtual void ChangeState(state nextState)
    {
        if ((currentState == state.Evade && nextState == state.Wander && _evadeTarget != null) ||
            (currentState == state.Pursuit && nextState == state.Wander && (_pursuitTarget != null) && !(!canReproduce && _pursuitTarget.tag == tag)) ||
            (currentState == state.Evade && nextState == state.Pursuit) ||
            currentState == nextState)
        {
            return;
        }

        StopCoroutine(currentState.ToString());
        currentState = nextState;
        StartCoroutine(currentState.ToString());
    }
예제 #14
0
    private void fearManager()
    {
        currentFear += Time.deltaTime * scareInc;
        if (currentFear > 0.0f && currentFear - Time.deltaTime * scareDec > 0.0f)
        {
            currentFear -= Time.deltaTime * scareDec;
        }
        else
        {
            currentFear = 0.0f;
        }

        FearMeter.updateMeter(currentFear / MAXFEAR);
        FearState.updateFearState(scaredState.ToString());
    }
예제 #15
0
        private static void printState(MSLLHOOKSTRUCT m)
        {
            new System.Threading.Tasks.Task(() =>
            {
                try
                {
                    var data = GetWindowDetailsFromPoint(m.pt);

                    Console.WriteLine($"({m.pt.x},{m.pt.y})" +
                                      $"\t{((HotkeyState == 0) ? "" : HotkeyState.ToString()),12}" +
                                      $"\t{data.Title, 40}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }).Start();
        }
    void touch(string name)
    {
        if (GameManager.touchable)
        {
            SoundManager.Instance.PlaySE(0);
            setTouch(false);
            if (name == "next")
            {
                stateUp();
            }
            else if (name == "answer")
            {
                checkAnswer();
            }
            if (name == "optionbutton")
            {
                before = state.MENU;
                gm.SendMessage(name + "Ev");

                /*} else if (name == "closeth") {
                 * gm.SendMessage (name + "Ev");*/
            }
            else
            {
                if (gstate == state.INTROEND)
                {
                    gm.SendMessage("toGameEv");
                }
                else
                {
                    gm.SendMessage(gstate.ToString("F") + "Ev");
                }
            }
        }
        else
        {
            Debug.Log("CANT TOUCH");
            return;
        }
    }
예제 #17
0
        /// <summary>
        /// Запуск автомата с входной строкой.
        /// </summary>
        /// <param name="tape"/> Входная строка.
        public void Run(string tape)
        {
            SetNullState();
            tape += '&';
            for (int i = 0; i < tape.Length; i++)
            {
                JumpFunction.Add(new String[] { new string(stack.ToArray()), st.ToString(), tape.Substring(i, tape.Length - i) });
                for (int m = 0; m < 5 //rules.Rank
                     ; m++)
                {
                    if ((st == (state)rules[m, st0]) &&
                        (tape[i] == (char)rules[m, inCh]) &&
                        (stack[0] == (char)rules[m, stckTop]))
                    {
                        st = (state)rules[m, st1];
                        //(IntPtr)rules[m, doing]('0');
                        switch (rules[m, doing])
                        {
                        case action.push:
                            push('0');
                            break;

                        case action.pop:
                            pop();
                            break;

                        case action.confirm:
                            confirm();
                            break;
                        }
                        break;
                    }
                    if (m == 4)
                    {
                        return;
                    }
                }
            }
        }
예제 #18
0
    public override string ToString(string indent)
    {
        string s = indent
                   + "<" + begin.ToString() + "-->" + end.ToString() + ">"
                   + " RULE: "
                   + rule + "\n";
        // string s = indent + "RULE: " + rule + "\n";
        string tmp = "";

        for (state p = rightmost; p != below; p = p.below)
        {
            tmp = p.ToString(indent + ". ") + tmp;
        }
        s += tmp;
        if (queue != null)
        {
            foreach (nonterminalState nt in queue)
            {
                s += indent + "ALTERNATE:\n";
                s += nt.ToString(indent);
            }
        }
        return(s);
    }
예제 #19
0
 /// <summary>
 /// 获取状态
 /// </summary>
 /// <returns>string</returns>
 public string GetCurrentstate()
 {
     return(currentstate.ToString());
 }
예제 #20
0
파일: Form1.cs 프로젝트: elipwns/GUI
 //pencil selected
 private void buttonPencil_Click(object sender, EventArgs e)
 {
     currentstate          = state.Pencil;
     textBoxStatusBar.Text = currentstate.ToString();
 }
예제 #21
0
파일: Form1.cs 프로젝트: elipwns/GUI
 //select the a rect button has been pressed
 private void buttonRectSelect_Click(object sender, EventArgs e)
 {
     currentstate          = state.RectSelect;
     textBoxStatusBar.Text = currentstate.ToString();
 }
예제 #22
0
파일: Form1.cs 프로젝트: elipwns/GUI
 //draw elipse selected
 private void buttonDrawElipse_Click(object sender, EventArgs e)
 {
     currentstate          = state.DrawElipse;
     textBoxStatusBar.Text = currentstate.ToString();
 }
예제 #23
0
 private void Start()
 {
     Stat      = state.move;
     text.text = Stat.ToString();
 }
 public string getCurrentStateName()
 {
     return(currentState.ToString());
 }
예제 #25
0
        public rawType[] filter(ref List <int> stimIndices, ref rawType[][] filtData, int channel)
        {
            //grab old data from previous buffer load
            for (int i = 0; i < PRE + POST; i++)
            {
                source[i] = previousData[i];
            }

            //grab new data from this buffer load
            for (int i = 0; i < bufferlength; i++)
            {
                source[i + PRE + POST] = filtData[channel][i];
            }

            //store unused buffer data for next time
            for (int i = 0; i < PRE + POST; i++)
            {
                //if we don't have enough samples in the filtData buffer to fill up previousData, use data already in previousData
                if (i < (PRE + POST) - bufferlength)
                {
                    previousData[i] = previousData[i + bufferlength];
                }
                else
                {
                    previousData[i] = filtData[channel][i + bufferlength - (PRE + POST)];
                }
            }

            t_stream = PRE;//what sample are we currently on?
            t_limit  = bufferlength + PRE;
            dest     = new rawType[bufferlength];

            int t_nextPeg;
            int t_processTo;

            toPeg = false;

            while (t_stream < t_limit)
            {
                //look for pegs between PRE+t_ahead and PRE+POST+bufferlength in the source buffer
                //- this corresponds to -POST+t_ahead through bufferlength in the stimindices/filtdata
                t_nextPeg = t_limit;          //if we don't have an upcoming peg
                while (stimIndices.Count > 0) //look for a peg
                {
                    if ((stimIndices[0] + PRE + POST) < (t_ahead + t_stream))
                    {
                        stimIndices.RemoveAt(0); //pop off
                    }
                    else
                    {
                        toPeg = false;
                        if (stimIndices[0] <= bufferlength + tau + t_ahead) // peg is somewhere we care about
                        {
                            t_nextPeg   = stimIndices[0] + PRE + POST;      //convert from real samples to buffered samples
                            t_processTo = t_nextPeg;
                            stimIndices.RemoveAt(0);
                            source[t_nextPeg] = railHigh + 0.01;//in order to force a peg, I just set the damn trace to railHigh where it should peg.
                            toPeg             = true;
                        }
                        break;
                    }
                }


                //set limit

                t_processTo = Math.Min(t_nextPeg, t_limit);


                while (t_stream < t_processTo)//process up to the next peg
                {
                    #region statemachine
                    switch (elecState)
                    {
                    case state.PEGGED:    //you should only be in this state if you are pegged and passing a zero
                        #region PEGGED
                        //if we actually are pegged right now, keep trucking
                        if (ispegged(source[t_stream]))
                        {
                            dest[t_stream - PRE] = 0;
                            t_stream++;
                            break;
                        }
                        //look ahead 2*N samples for another peg.  If you find one, force a peg
                        for (int dt = 1; dt <= 2 * tau; dt++)
                        {
                            if (ispegged(source[t_stream + dt]))
                            {
                                t0        = t_stream + dt;//the location of the peg
                                elecState = state.FORCEPEG;
                                break;
                            }
                        }
                        if (elecState == state.FORCEPEG)
                        {
                            break;
                        }
                        else
                        {
                            t0 = t_stream + tau + 1;  //location of when we are clear//HACK
                            calc_X012(); calc_X3();
                            calc_alpha0123();
                            toopoorcnt = TOOPOORCNT;
                            delaycnt   = 0;
                            elecState  = state.TOOPOOR;
                        }
                        #endregion
                        break;

                    case state.FORCEPEG:    //you should only be in this state is you aren't pegged right now but you will be so soon that it isn't worth trying to fit anything.
                        #region FORCEPEG
                        if (t_stream < t0)
                        {
                            dest[t_stream - PRE] = 0;
                            t_stream++;
                        }
                        else
                        {
                            elecState = state.PEGGED;
                        }

                        #endregion
                        break;

                    case state.TOOPOOR:    //you should only be in this state if you haven't been able to get an asymmetric fit after a peg
                        #region TOOPOOR
                        //delaycnt = 0;
                        double asym = 0;
                        double sig  = 0;

                        //calculate asymmetry
                        for (int i = 0; i < t_chi2; i++)
                        {
                            int    t_i = t_stream + i;
                            double dt  = t_i - t0;
                            double dt2 = dt * dt;
                            double dt3 = dt * dt2;
                            double dy  = alpha0 + alpha1 * dt + alpha2 * dt2 + alpha3 * dt3 - source[t_i];
                            asym += dy;
                            sig  += dy * dy;
                        }
                        asym *= asym;
                        if (asym < my_thresh)
                        {
                            toopoorcnt--;
                        }
                        else
                        {
                            toopoorcnt = TOOPOORCNT;
                        }

                        //have we met the criteria for a good fit?
                        if ((toopoorcnt <= 0) && (asym < my_thresh / 3.92))
                        {
                            double dt  = t_stream - t0;
                            double dt2 = dt * dt;
                            double dt3 = dt * dt2;
                            negv = source[t_stream] < (alpha0 + alpha1 * dt + alpha2 * dt2 + alpha3 * dt3);
                            //int_t x0=X0,x1=X1,x2=X2,x3=X3;//I can't find where these are used.
                            calc_X012(); calc_X3();     // for numerical stability problem!
                            elecState = state.BLANKDEPEG;
                            //System.Console.Write(channel.ToString() + " delay " + (delaycnt).ToString() + ":");
                            break;
                        }

                        //fit isn't good enough yet- blank and go on to next time step
                        dest[t_stream - PRE] = 0;    // 1 + asym - my_thresh;
                        t_stream++; t0++; delaycnt++;
                        if (t_stream == t_processTo)
                        {
                            break;    //
                        }
                        //do we need to force a peg?

                        if (ispegged(source[t0 + tau + t_ahead]))
                        {
                            t0        = t0 + tau;
                            elecState = state.FORCEPEG;
                            break;
                        }

                        //if not, recalculate the curve
                        update_X0123();
                        //int_t x0=X0,x1=X1,x2=X2,x3=X3;//I can't find where these lower case values are used
                        calc_X012(); calc_X3();     // for numerical stability problem!
                        calc_alpha0123();
                        #endregion
                        break;

                    case state.BLANKDEPEG:    //you should only be in this state if you have met the asymmetry requirement of the TOOPOOR state but you still have misgivings about curve fitting.
                        #region BLANKDEPEG
                    {
                        if (t_stream >= t0 - tau + t_blankdepeg)
                        {
                            elecState = state.DEPEGGING;
                            break;
                        }


                        //double dt = t_stream - t0;
                        //double dt2 = dt * dt;
                        //double dt3 = dt * dt2;
                        //rawType y = source[t_stream] - (rawType)(alpha0 + alpha1 * dt + alpha2 * dt2 + alpha3 * dt3);
                        //if ((y < 0) != negv)
                        //{
                        //    dest[t_stream-PRE] = y;
                        //    t_stream++;
                        //    elecState = state.DEPEGGING;
                        //    break;
                        //}

                        dest[t_stream - PRE] = 0;
                        t_stream++;
                    }
                        #endregion
                        break;

                    case state.DEPEGGING:    //you should only be in this state if you are ready to curve fit, but the peg occured as few as N (tau) samples ago
                        #region DEPEGGING
                    {
                        if (t_stream == t0)
                        {
                            elecState = state.OK;
                            break;
                        }
                        double dt  = t_stream - t0;
                        double dt2 = dt * dt;
                        double dt3 = dt * dt2;
                        dest[t_stream - PRE] = source[t_stream]
                                               - (rawType)(alpha0 + alpha1 * dt + alpha2 * dt2 + alpha3 * dt3);
                        t_stream++;
                    }
                        #endregion
                        break;

                    case state.OK:    //you should only be in this state if you are ready to curve fit, and you have N (tau) samples in either direction to curve fit with
                        #region OK
                        calc_alpha0();
                        dest[t_stream - PRE] = source[t_stream] - (rawType)(alpha0);    //source[t_stream] - X0;//
                        t_stream++;
                        //we are in the okay state- so check to see if going to peg or trigger a peg soon.
                        if (ispegged(source[t_stream + tau + t_ahead]))
                        {
                            t0 = t_stream - 1;
                            calc_X3();
                            calc_alpha0123();
                            elecState = state.PEGGING;
                            break;
                        }
                        update_X012();

                        #endregion
                        break;

                    case state.PEGGING:
                        #region PEGGING
                    {
                        if (t_stream >= t0 + tau)
                        {
                            //t_peg = t_stream;//used to report a peg
                            elecState = state.PEGGED;
                            break;
                        }
                        double dt  = t_stream - t0;
                        double dt2 = dt * dt;
                        double dt3 = dt * dt2;
                        dest[t_stream - PRE] = source[t_stream]
                                               - (rawType)(alpha0 + alpha1 * dt + alpha2 * dt2 + alpha3 * dt3);
                        t_stream++;
                    }
                        #endregion
                        break;

                    default:
                        throw new Exception("SALPA error:  sample " + t_stream.ToString() + " with unknown state " + elecState.ToString());
                    }
                    #endregion
                }

                //we just processed through t_processto
                if (toPeg & (t_processTo == t_nextPeg))
                {
                    t0        = t_stream + forcepegsamples;
                    elecState = state.FORCEPEG;
                    toPeg     = false;
                }
            }

            t0 = t0 - t_stream + PRE;

            return(dest);
        }
예제 #26
0
 protected void ChangeState(state s)
 {
     Log.log("State change: " + s.ToString());
     CurrentState = s;
 }
예제 #27
0
    /////////////////////////////////////////////////////////////////////
    /// --- Public functions ---
    /////////////////////////////////////////////////////////////////////

    //Returns the exact state of the player, as a string
    //States are:
    //	"active" | alive, movable and succeptible to damage
    //  "inactive" | alive, but in a cinematic state or similarly frozen
    //  "dead" | not so alive
    //	"invulnerable" | alive, but invulnerable
    public string GetState()
    {
        return(playerState.ToString());
    }
예제 #28
0
    private static IGame ReadText(string path, IGame game)
    {
        string[] lines = File.ReadAllLines(path);
        LogHandler.NewEntry("Line count " + lines.Length);

        state state = state.None;

        List <state> StateHist = new List <state>();

        object CurrentDefinition = null;

        for (int i = 0; i < lines.Length; i++)
        {
            string line = lines[i];

            //LogHandler.NewEntry("Reading Line "+ '"' + line + '"');
            {
                line = line.Replace("\t", "").Replace("\r", "").Replace("\n", "");

                if (line.LastIndexOf("  ") > -1)
                {
                    line = line.Remove(line.LastIndexOf("  "));
                }

                if (line.Contains("\\"))
                {
                    line = line.Remove(line.IndexOf("\\"));
                }
                if (line.Contains("##"))
                {
                    line = line.Remove(line.IndexOf("##"));
                }
                if (line.Contains("//"))
                {
                    line = line.Remove(line.IndexOf("//"));
                }

                if (string.IsNullOrWhiteSpace(line))
                {
                    LogHandler.NewEntry("Formated Line is Null, Continuing to next line");
                    continue;
                }
            }

            LogHandler.NewEntry("Formated Line #" + i + " " + '"' + line + '"');

            if (line.Contains("}"))
            {
                switch (state)
                {
                case state.NewEffect:
                {
                    Effect effect = CurrentDefinition as Effect;
                    game.Effects.Add(effect.Name, effect);
                    LogHandler.NewEntry("New Effect added to the game \n" + effect.ToLongString());
                    CurrentDefinition = null;
                }
                break;

                case state.SetSprite:
                {
                    Effect effect = CurrentDefinition as Effect;
                    effect.Sprite.GetSprites();
                    LogHandler.NewEntry("Sprites set to the effect " + effect.Name + " Sprites Count: " + effect.Sprite.Sprites.Count);
                }
                break;
                }
                if (StateHist.Count > 1)
                {
                    LogHandler.NewEntry("Exiting the state " + state.ToString());
                    state = StateHist[StateHist.Count - 1];
                    StateHist.RemoveAt(StateHist.Count - 1);
                    LogHandler.NewEntry("New State: " + state.ToString());
                }
                if (line == "}")
                {
                    continue;
                }
            }
            if (line.Contains("{"))
            {
                switch (state)
                {
                case state.NewEffect:
                {
                    CurrentDefinition = new Effect();
                    LogHandler.NewEntry("Creating new Effect");
                }
                break;
                }
                if (line == "{")
                {
                    continue;
                }
            }

            switch (state)
            {
            case state.None:
                switch (line.ToUpper().Replace(" ", string.Empty))
                {
                case "DEFINITION":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Entering the Definition of new Classes");
                    state = state.Definition;
                    break;
                }
                break;

            case state.Definition:
                switch (line.ToUpper().Replace(" ", string.Empty))
                {
                case "EFFECT":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Creating new Effect");
                    state = state.NewEffect;
                    break;
                }
                break;

            case state.NewEffect:
            {
                Effect   effect        = CurrentDefinition as Effect;
                string[] separatedLine = line.Split('=');
                switch (separatedLine[0].ToUpper().Replace(" ", string.Empty))
                {
                case "NAME":
                    effect.SetName(separatedLine[1]);
                    LogHandler.NewEntry("Effect name is " + separatedLine[1]);
                    break;

                case "FREQUENCY":
                    switch (separatedLine[1].ToUpper().Replace(" ", string.Empty))
                    {
                    case "PERIODICAL":
                        LogHandler.NewEntry("Effect Activation found: " + '"' + separatedLine[1] + '"');
                        effect.SetActivation(ActivationType.Periodical);
                        break;

                    case "ONCE":
                        LogHandler.NewEntry("Effect Activation found: " + '"' + separatedLine[1] + '"');
                        effect.SetActivation(ActivationType.Once);
                        break;

                    case "TRIGERRED":
                        LogHandler.NewEntry("Effect Activation found: " + '"' + separatedLine[1] + '"');
                        effect.SetActivation(ActivationType.Triggered);
                        break;

                    default:
                        LogHandler.NewEntry("Effect Activation not found, line is " + '"' + separatedLine[1] + '"', true);
                        break;
                    }
                    break;

                case "DAMAGE":
                    LogHandler.NewEntry("Effect Damage found: " + '"' + separatedLine[1].Replace(" ", string.Empty) + '"');
                    effect.SetDamage(float.Parse(separatedLine[1].Replace(" ", string.Empty)));
                    break;

                case "DURATION":
                    LogHandler.NewEntry("Effect Duration found: " + '"' + separatedLine[1].Replace(" ", string.Empty) + '"');
                    effect.SetDuration(float.Parse(separatedLine[1].Replace(" ", string.Empty)));
                    break;

                case "INTERVAL":
                    LogHandler.NewEntry("Effect Interval found: " + '"' + separatedLine[1].Replace(" ", string.Empty) + '"');
                    effect.SetInterval(float.Parse(separatedLine[1].Replace(" ", string.Empty)));
                    break;

                case "SPRITE":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Setting Sprite proprieties");
                    state = state.SetSprite;
                    break;

                case "MODIFIEDBY":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Setting effect Modifiers");
                    state = state.SetModifiedBy;
                    break;

                case "INFLICTWHEN":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Setting effect Inflicted When Conditions");
                    state = state.SetInflictIfConditions;
                    break;

                case "TRIGGERWHEN":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Setting effect Trigger When Conditions");
                    state = state.SetTriggerIfConditions;
                    break;

                case "STOPWHEN":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Setting effect Stop When Conditions");
                    state = state.SetStopIfConditions;
                    break;

                case "REMOVEWHEN":
                    StateHist.Add(state);
                    LogHandler.NewEntry("Setting effect Remove When Conditions");
                    state = state.SetRemoveIfConditions;
                    break;

                default:
                    break;
                }
            }
            break;

            case state.SetModifiedBy:
            {
                Effect   effect        = CurrentDefinition as Effect;
                string[] separatedLine = line.Split(':');
                switch (separatedLine[0].ToUpper())
                {
                case "DAMAGE":
                    LogHandler.NewEntry("Effect " + effect.Name + "'s Damage will be modified by " + separatedLine[2] + " when " + separatedLine[1] + " is present.");
                    effect.ModifiedBy.Add(separatedLine[1] + " DAMAGE", new Tuple <Modifiable, float>(Modifiable.Damage, float.Parse(separatedLine[2])));
                    break;

                case "DURATION":
                    LogHandler.NewEntry("Effect " + effect.Name + "'s Duration will be modified by " + separatedLine[2] + " when " + separatedLine[1] + " is present.");
                    effect.ModifiedBy.Add(separatedLine[1] + " DURATION", new Tuple <Modifiable, float>(Modifiable.Duration, float.Parse(separatedLine[2])));
                    break;

                case "INTERVAL":
                    LogHandler.NewEntry("Effect " + effect.Name + "'s Interval will be modified by " + separatedLine[2] + " when " + separatedLine[1] + " is present.");
                    effect.ModifiedBy.Add(separatedLine[1] + " INTERVAL", new Tuple <Modifiable, float>(Modifiable.Interval, float.Parse(separatedLine[2])));
                    break;

                default:
                    LogHandler.NewEntry("Could not set modifier.");
                    break;
                }
            }
            break;

            case state.SetInflictIfConditions:
            {
                Effect   effect        = CurrentDefinition as Effect;
                string[] separatedLine = line.Split(':');
                switch (separatedLine[0].ToUpper())
                {
                case "EFFECT":
                    effect.InflictIf.Add(separatedLine[2], new System.Tuple <string, OperatorType, string>(separatedLine[0], separatedLine[1].Contains("Have") ? OperatorType.Have : OperatorType.NotHave, separatedLine[2]));
                    break;

                case "HEALTH":
                    switch (separatedLine[1])
                    {
                    case ">":
                        effect.InflictIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerThan, separatedLine[2]));
                        break;

                    case ">=":
                        effect.InflictIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerOrEqualsThan, separatedLine[2]));
                        break;

                    case "=":
                        effect.InflictIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.EqualsTo, separatedLine[2]));
                        break;

                    case "<=":
                        effect.InflictIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerOrEqualsThan, separatedLine[2]));
                        break;

                    case "<":
                        effect.InflictIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerThan, separatedLine[2]));
                        break;
                    }
                    break;
                }
            }
            break;

            case state.SetTriggerIfConditions:
            {
                Effect   effect        = CurrentDefinition as Effect;
                string[] separatedLine = line.Split(':');
                switch (separatedLine[0].ToUpper())
                {
                case "EFFECT":
                    effect.TriggerIf.Add(separatedLine[2], new System.Tuple <string, OperatorType, string>(separatedLine[0], separatedLine[1].Contains("Have") ? OperatorType.Have : OperatorType.NotHave, separatedLine[2]));
                    break;

                case "HEALTH":
                    switch (separatedLine[1])
                    {
                    case ">":
                        effect.TriggerIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerThan, separatedLine[2]));
                        break;

                    case ">=":
                        effect.TriggerIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerOrEqualsThan, separatedLine[2]));
                        break;

                    case "=":
                        effect.TriggerIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.EqualsTo, separatedLine[2]));
                        break;

                    case "<=":
                        effect.TriggerIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerOrEqualsThan, separatedLine[2]));
                        break;

                    case "<":
                        effect.TriggerIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerThan, separatedLine[2]));
                        break;
                    }
                    break;
                }
            }
            break;

            case state.SetStopIfConditions:
            {
                Effect   effect        = CurrentDefinition as Effect;
                string[] separatedLine = line.Split(':');
                switch (separatedLine[0].ToUpper())
                {
                case "EFFECT":
                    effect.StopIf.Add(separatedLine[2], new System.Tuple <string, OperatorType, string>(separatedLine[0], separatedLine[1].Contains("Have") ? OperatorType.Have : OperatorType.NotHave, separatedLine[2]));
                    break;

                case "HEALTH":
                    switch (separatedLine[1])
                    {
                    case ">":
                        effect.StopIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerThan, separatedLine[2]));
                        break;

                    case ">=":
                        effect.StopIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerOrEqualsThan, separatedLine[2]));
                        break;

                    case "=":
                        effect.StopIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.EqualsTo, separatedLine[2]));
                        break;

                    case "<=":
                        effect.StopIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerOrEqualsThan, separatedLine[2]));
                        break;

                    case "<":
                        effect.StopIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerThan, separatedLine[2]));
                        break;
                    }
                    break;
                }
            }
            break;

            case state.SetRemoveIfConditions:
            {
                Effect   effect        = CurrentDefinition as Effect;
                string[] separatedLine = line.Split(':');
                switch (separatedLine[0].ToUpper())
                {
                case "EFFECT":
                    effect.RemoveIf.Add(separatedLine[2], new System.Tuple <string, OperatorType, string>(separatedLine[0], separatedLine[1].Contains("Have") ? OperatorType.Have : OperatorType.NotHave, separatedLine[2]));
                    break;

                case "HEALTH":
                    switch (separatedLine[1])
                    {
                    case ">":
                        effect.RemoveIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerThan, separatedLine[2]));
                        break;

                    case ">=":
                        effect.RemoveIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.BiggerOrEqualsThan, separatedLine[2]));
                        break;

                    case "=":
                        effect.RemoveIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.EqualsTo, separatedLine[2]));
                        break;

                    case "<=":
                        effect.RemoveIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerOrEqualsThan, separatedLine[2]));
                        break;

                    case "<":
                        effect.RemoveIf.Add("HEALTH", new System.Tuple <string, OperatorType, string>(separatedLine[0], OperatorType.LowerThan, separatedLine[2]));
                        break;
                    }
                    break;
                }
            }
            break;

            case state.SetSprite:
            {
                Effect   effect        = CurrentDefinition as Effect;
                string[] separatedLine = line.Split('=');
                switch (separatedLine[0].ToUpper().Replace(" ", string.Empty))
                {
                case "ANIMATED":
                    LogHandler.NewEntry("Sprite Animation type found: " + '"' + separatedLine[1] + '"');
                    effect.Sprite.SetAnimated(bool.Parse(separatedLine[1]));
                    break;

                case "FILE":
                    string TexturePath = path.Remove(path.LastIndexOf(@"\") + 1);
                    TexturePath += separatedLine[1];
                    LogHandler.NewEntry("Sprite file path found: " + '"' + TexturePath + '"');

                    effect.Sprite.SetPath(TexturePath);
                    break;

                case "SIZE":
                    StateHist.Add(state);
                    state = state.GetSpriteSizes;
                    break;
                }
            }
            break;

            case state.GetSpriteSizes:
            {
                Effect effect = CurrentDefinition as Effect;

                line = FilterString(line, Numeric);

                if (SpriteSize.Contains(line))
                {
                    effect.Sprite.Sprites.Add(int.Parse(line), null);
                }
            }
            break;
            }
        }

        foreach (Effect e in game.Effects.Values)
        {
            Debug.Log(e.ToLongString());
        }

        return(game);
    }
예제 #29
0
 public void showResults()
 {
     Console.WriteLine(_name + " at Position " + _position.X + " in X and Position " + _position.Y + " in Y;" + " His state is : " + _state.ToString());
 }