Example #1
0
 public void Setup()
 {
     _x = Mathf.Abs(gameObject.transform.localScale.x);
     now = state.set;
     isShowing = false;
     alive = true;
 }
Example #2
0
    void runStates()
    {
        switch (currentState)
        {
            case state.idle:
                rigid.velocity = Vector3.zero;
                float dist = Vector3.Distance(transform.position, PlayerCharacter.instance.transform.position);
                if (dist < triggerDistance)
                {
                    currentState = state.shooting;
                }
                break;
            case state.shooting:
                shootPlayer();
                float currentDist = Vector3.Distance(transform.position, PlayerCharacter.instance.transform.position);
                if (currentDist > triggerDistance)
                {
                    currentState = state.idle;
                }
                break;
            case state.knockback:
                knockback();
                if (!inKnockback)
                {
                    currentState = state.idle;
                }
                break;
        }

        if (inKnockback)
        {
            currentState = state.knockback;
        }
    }
Example #3
0
 bool getAccountInfo(string[] parts, state reason)
 {
     if (parts [0].Replace (" ", "").Equals ("") || parts [1].Replace (" ", "").Equals ("") || parts [2].Replace (" ", "").Equals ("")) {
         Debug.Log("Error!");
         if (reason == state.login){
             return false;
         } else
             return true;
     }
     if (reason == state.register) {
         if (!parts [2].Contains ("@")) {
             Debug.Log ("Invalid Email");
             return true;
         }
         foreach(String s in invalidPassChars){
             if (parts [1].Contains (s)) {
                 Debug.Log ("Invalid characters in password");
                 return true;
             }
         }
         foreach(String s in invalidUserChars){
             if (parts [0].Contains (s)) {
                 Debug.Log ("Invalid characters in username");
                 return true;
             }
         }
     }
     if (reason == state.login && parts [0].Replace(" ", "`").ToLower().Equals (loginUser.text.Replace(" ", "`").ToLower()) && parts [1].Equals (loginPass.text)) {
         return true;
     }
     if (reason == state.register && parts [0].Equals (username.text)) {
         return true;
     }
     return false;
 }
Example #4
0
 // Кнопка "=" - считает результат по тому статусу, который выполняется
 private void button16_Click(object sender, EventArgs e)
 {
     try
     {
         // если текущий статус деление
         if (CurrentState == state.divide)
         {
             CurrentState = state.nonstate;
             double buff2 = double.Parse(textBox1.Text);
             textBox1.Text = (double.Parse(buff) / buff2).ToString();
         }                // если текущий статус умножение
         if (CurrentState == state.multiplication)
         {
             CurrentState = state.nonstate;
             double buff2 = double.Parse(textBox1.Text);
             textBox1.Text = (double.Parse(buff) * buff2).ToString();
         }                // если текущий статус деление
         if (CurrentState == state.substraction)
         {
             CurrentState = state.nonstate;
             double buff2 = double.Parse(textBox1.Text);
             textBox1.Text = (double.Parse(buff) - buff2).ToString();
         }                // если текущий статус добавление
         if (CurrentState == state.addiction)
         {
             CurrentState = state.nonstate;
             double buff2 = double.Parse(textBox1.Text);
             textBox1.Text = (double.Parse(buff) + buff2).ToString();
         }
     }
     catch(Exception)
     {
         MessageBox.Show("Введены некорректные данные");
     }
 }
Example #5
0
 public void changestate(state newstate)
 {
     if(currentState != null)
         currentState.Exit();
     currentState = newstate;
     currentState.Enter(this);   
 }
Example #6
0
        public state closestGoodPred(state s, bool updateCosts = true)
        {
            //'moves' robot's logical position to the closest NOT-dead-end node to s out of S's predecessors. Required to avoid massive recalculations on mapping own position's cost to infinity.
            List<state> preds = new List<state>();
            Dictionary<state, state> succ = new Dictionary<state, state>();
            preds.Add(s);
            state cur = s;
            while (isDeadEnd(cur))
            {
                foreach (state ss in predecessors(cur))
                {
                    preds.Add(ss);
                    if(!succ.ContainsKey(ss))succ.Add(ss, cur);
                }
                cur = preds[0];
                preds.Remove(cur);

            }
            state ini = cur;
            while (equals(ini , s) && false)
            {
                //setCost(ini, costs[ini.x,ini.y]);
                ini = succ[ini];
            }
            return cur;
        }
Example #7
0
	void LateUpdate()
	{
		if (target != null)
		{
			if (panState == state.pantoward)
			{
				player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
				camPos = Vector3.SmoothDamp(camPos, new Vector3(target.transform.position.x, target.transform.position.y, camPos.z), ref currentVelocity, panTime);
				Camera.main.transform.position = camPos;
				Debug.Log(currentVelocity);
				if (Vector2.Distance(camPos, target.transform.position) < 0.1f)
				{
					Invoke("startPanBack", stayTime);
					panState = state.panwait;
				}
			}
			else if (panState == state.panback)
			{
				camPos = Vector3.SmoothDamp(camPos, new Vector3(player.position.x, player.position.y, camPos.z), ref currentVelocity, panTime);
				Camera.main.transform.position = camPos;
				if (Vector2.Distance(camPos, player.position) < 0.1f)
				{
					Camera.main.GetComponent<CameraController>().enabled = true;
					panState = state.notpanning;
				}
			}
		}
	}
Example #8
0
    public void createModuleContainer()
    {
        this.transform.gameObject.GetComponent<ModuleContainer>().show();
        show_interface = state.Module;

        disableCamera();
    }
 public void play()
 {
     MainWindow1.Title = System.IO.Path.GetFileNameWithoutExtension(med.chemin[i]);
     mediaElement.Play();
     play_state = state.play;
     play_button.Content = WebUtility.HtmlDecode("&#xE769;");
 }
Example #10
0
    public void OnRevolution()
    {
        if(currentState == state.MOVING){//start a dive if a dive isn't already in progress
            currentState = state.DIVING;
            radii.y = -0.2f;
            radii.z = -diveAcc;
        }

        if(mode >= 1){//gain speed
            if(thetas.y < maxSpeed){
                thetas.y += speedPerRevolution;
                if(thetas.y > maxSpeed)
                    thetas.y = maxSpeed;
            }
        }
        if(mode >= 2){//enemies gain speed
            List<Enemy> enemylist = Dial.GetAllEnemies();
            foreach(Enemy e in enemylist){
                GameObject zappything = GameObject.Instantiate(Resources.Load ("Prefabs/MainCanvas/ZappyThing")) as GameObject;
                zappything.GetComponent<RectTransform>().sizeDelta = e.GetComponent<RectTransform>().sizeDelta * 1.7f;
                zappything.GetComponent<Lifespan>().BeginLiving(3f);
                zappything.GetComponent<Lifespan>().SetImageToFade(true);
                zappything.transform.SetParent(e.transform,false);

                e.SpeedUp(enemyBoostMultiplier,enemyBoostDuration);
            }
        }
        if(mode >= 3){//gain life drain
            lifeDrain += lifeDrainPerRevolution;
        }
    }
Example #11
0
        public Dialog(Point Position, Size Size, string Caption = "", string Text = "", int Depth = 0, state Type = state.message, Form1 f = null)
        {
            this.Position = Position;
            this.Size = Size;
            this.Caption = Caption;
            this.Text = Text;
            this.Depth = Depth;
            this.Type = Type;

            nextDialog = null;
            Id = Globalization.setId();
            DialogueStart = false;
            nextDialogID = -1;
            Rotation = 0;
            nextDialogBranch = null;
            nextDialogBranchId = -1;
            nextConditionDialog = null;
            nextActionDialog = null;
            messageAttachedWire = -1;
            startPosition = Position;
            startPositionUnzoomed = Position;
            Rotation = 0;

            Update(f);
        }
 //couroutine change AI state with a delay time
 IEnumerator ChangeAIStateDelay(state currstate, float time)
 {
     yield return new WaitForSeconds(time);
     currState = currstate;
     //shootCheck = false;
     StopCoroutine("ChangeAIStateDelay");
 }
Example #13
0
    void runStates()
    {
        switch(currentState)
        {
            case state.idle:
                float dist = Vector3.Distance(transform.position, PlayerCharacter.instance.transform.position);
                if(dist < triggerDistance)
                {
                    currentState = state.following;
                }
                break;
            case state.following:
                followPlayer();
                break;
            case state.knockback:
                knockback();
                if (!inKnockback)
                {
                    currentState = state.idle;
                }
                break;
        }

        if (inKnockback)
        {
            currentState = state.knockback;
        }
    }
Example #14
0
    public void destroyModuleContainer()
    {
        this.transform.gameObject.GetComponent<ModuleContainer>().hide();
        show_interface = state.Clear;

        enableCamera();
    }
Example #15
0
    void OnGUI()
    {
        GUI.skin.box.wordWrap = true;
        //new Rect(left,top,width,height)
        if (currentState == state.main) {
            if (GUI.Button (new Rect (Screen.width * 0.2f, Screen.height * 0.1f, Screen.width * 0.6f, Screen.height * 0.15f), "New Game")) {
                Inventory.artificials = new SplayTree<Artificial> ();
                Application.LoadLevel ("Forest");
            }
            if (GUI.Button (new Rect (Screen.width * 0.2f, Screen.height * 0.3f, Screen.width * 0.6f, Screen.height * 0.15f), "Load Game")) {
                UniverseSaveObject.LoadUniverse ();
                Application.LoadLevel ("Forest");
            }
            if (GUI.Button (new Rect (Screen.width * 0.2f, Screen.height * 0.5f, Screen.width * 0.6f, Screen.height * 0.15f), "Story")) {
                currentState = state.story;
            }
            if (GUI.Button (new Rect (Screen.width * 0.2f, Screen.height * 0.7f, Screen.width * 0.6f, Screen.height * 0.15f), "Quit"))
                currentState = state.quit;
        }
        if (currentState == state.quit) {
            if(GUI.Button(new Rect(Screen.width*0.2f,Screen.height*0.35f,Screen.width*0.2f,Screen.height*0.3f),"No"))
                currentState=state.main;

            if(GUI.Button(new Rect(Screen.width*0.6f,Screen.height*0.35f,Screen.width*0.2f,Screen.height*0.3f),"Yes"))
                Application.Quit();
        }
        if (currentState == state.story) {
                GUI.Box(new Rect((Screen.width / 2) - (Screen.width/8), (Screen.height / 2) - (Screen.height / 8), Screen.width / 4, Screen.height / 4), "On a long space venture, you have lost your way! Your warp drive has quit and you've been thrown out of hyperspace surrounded by alien viruses. Gather resources to rebuild your warp drive and return to your home planet!");
        }

        //GUI.Button(new Rect(10,10,100,100),"New Game");
    }
Example #16
0
    public void destroyDialog()
    {
        this.transform.gameObject.GetComponent<CreateDialog>().hide();
        show_interface = state.Clear;

        enableCamera();
    }
        // private Thread aiThread;
        // private Thread collisionThread;
        public GameScene()
            : base()
        {
            LogCat.updateValue("Scene", "Game");

            halkFighters = new List<Fighter>();
            esxolusFighters = new List<Fighter>();
            spawnShips = new List<SpawnShip>();
            halkCapitalNodes = new List<Vector3>();
            esxolusCapitalNodes = new List<Vector3>();

            currentState = state.loading;

            collisionManager = new CollisionManager(1000000, 1000000, 1000000, 3);

            aiList = new List<AI>();
            turretList = new List<Turret>();
            particleGeneratorList = new List<ParticleGenerator>();
            /*aiThread = new Thread(new ThreadStart(AIThreadPoolCallback));
            aiThread.Start();
            aiThread.IsBackground = true;
            aiThread.Priority = ThreadPriority.Lowest;

            collisionThread = new Thread(new ThreadStart(CollisionThreadPoolCallback));
            collisionThread.Start();
            collisionThread.IsBackground = true;*/
        }
Example #18
0
    public void createDialog()
    {
        this.transform.gameObject.GetComponent<CreateDialog>().show();
        show_interface = state.Dialog;

        disableCamera();
    }
Example #19
0
 public override void LoadContent(ContentManager theContentManager)
 {
     base.LoadContent(theContentManager);
     position = new Vector2(80, 250);
     scale = 0.088f;
     myCurrentState = state.STANDING;
 }
Example #20
0
    public void LoadReceived()
    {
        received_state = state.LOADING;
        received.Clear();
        string url = SocialManager.Instance.FIREBASE + "/challenges.json";
            //?orderBy=\"time\"&limitToLast=30";
        url += "?orderBy=\"op_facebookID\"&equalTo=\"" + SocialManager.Instance.userData.facebookID + "\"";
        Debug.Log("LoadReceived: " + url);
        HTTP.Request someRequest = new HTTP.Request("get", url);
        someRequest.Send((request) =>
        {
            Hashtable decoded = (Hashtable)JSON.JsonDecode(request.response.Text);
            if (decoded == null)
            {
                Debug.LogError("server returned null or     malformed response ):");
                return;
            }

            foreach (DictionaryEntry json in decoded)
            {
                Hashtable jsonObj = (Hashtable)json.Value;
                PlayerData newData = new PlayerData();
                newData.objectID = (string)json.Key;
                newData.facebookID = (string)jsonObj["facebookID"];
                newData.playerName = (string)jsonObj["playerName"];
                newData.score = (int)jsonObj["score"];
                newData.score2 = (int)jsonObj["score2"];
                newData.winner = (string)jsonObj["winner"];
                newData.notificated = (bool)jsonObj["notificated"];
                received.Add(newData);
            }
            received_state = state.READY;
        });
    }
Example #21
0
    public void Activate()
    {
        clickedHex = null;
        MapController.hexSelected = null;

        currentState = state.ACTIVE;
        toggle.SetButtonState(true);
    }
        private void play()
        {

            MainWindow1.Title = System.IO.Path.GetFileNameWithoutExtension(_source[i]);
            mediaElement.Play();
            play_state = state.play;
            play_button.Content = "Pause";
        }
Example #23
0
	public void toggleInGameMenu() {
		if (paused()) {
			unpause();
		} else {
			pause();
			currentMenu = state.InGameMenu;
		}
	}
Example #24
0
 public void Reset()
 {
     // reset state
     mAni.SetInteger("Attack",(int)attacks.AttackSize);
     mFirstHit = false;
     transform.rotation = Quaternion.Euler (new Vector3 (0, 180, 0));
     currentState = state.pick;
     mCooldown = 0;
 }
Example #25
0
 public void duck()
 {
     if (risse.OnTheGround)
     {
         theState = state.ducking;
         risse.Animation = (int)state.ducking;
         //risse.Position = new Vector2(risse.Position.X, risse.Position.Y - 128);
     }
 }
 public void setState(int value)
 {
     currentState = (state)value;
     if (currentState != state.death) {
         animator.SetBool ("move", true);
     } else {
         animator.SetBool ("move", false);
     }
 }
Example #27
0
    bool readFile(state reason)
    {
        try{
                if (File.Exists (fileName)) {
                    StreamReader reader = new StreamReader(fileName, Encoding.Default);
                    string line;

                    using (reader){
                        do {
                            line = reader.ReadLine();
                            Debug.Log (line);
                        if (line != null){
                            foreach(char i in line){

                                //  Entries as user.password.email
                                string[] entries = line.Split('`');
                                if (entries.Length > 0){
                                    //Debug.Log (entries[0]);
                                    //Debug.Log (entries[1]);
                                    if (reason == state.login){
                                        if (getAccountInfo(entries, state.login)){
                                            canLogin = true;
                                            Debug.Log ("Password Correct! :)");
                                            return true;
                                        } else Debug.Log ("Username or password is incorrect!");
                                    } else {
                                        if (!getAccountInfo(entries, state.register)){
                                                canRegister = true;
                                                reader.Close ();
                                                writeFile();
                                                return true;
                                        } else {
                                            Debug.Log ("This account already exists!");
                                            return true;
                                        }
                                    }
                                }
                            }
                        } else {
                            if (reason == state.register){
                                reader.Close();
                                writeFile();
                            }
                        }
                    }
                        while (line != null);
                        reader.Close();
                        return true;
                    }
                }
                else Debug.Log("File doesn't exist.");
            return false;
            } catch (Exception e){
                Debug.Log(e.Message);
                return false;
            }
    }
Example #28
0
 public void Catch()
 {
     if(actualState == state.droped && controller.catchedObjects < 1)
     {
         controller.cachedId = name;
         actualState = state.catched;
         controller.catchedObjects++;
     }
 }
Example #29
0
    public void Activate(state newState)
    {
        Vector3 objectDim = gameObject.GetComponent<RectTransform>().sizeDelta;

        SetState(newState);
        CameraController.SetGameActive(false);

        gameObject.SetActive(true);
        myCollider.size = new Vector3(objectDim.x, objectDim.y, objectDim.z);
    }
    public void setState(int value)
    {
        currentState = (state)value;
        try{
            CancelInvoke("huntMovement");
        } catch {

        }
        stateChanged ();
    }
Example #31
0
    /*
     * This is a UnityEngine function defined by MonoBehaviour.
     * This function activates every 16.67 milliseconds (for 60 frames-per-second).
     *
     * Here, the Update function checks what this script's substate is, then takes the
     * appopriate action. Once this script's work is done, it transfers control to NextIceCube.
     */
    void Update()
    {
        if (substate == IceCollider.state.landedInCup)
        {
            //When cube islands in cup play IceInCup
            AudioSource audioSource = gameObject.AddComponent <AudioSource>();
            audioSource.clip = Resources.Load("Sounds/IceInCup") as AudioClip;
            audioSource.Play();
            //enable NextIceCube
            gameObject.GetComponent <NextIceCube>().enabled = true;
            gameObject.GetComponent <NextIceCube>().successThrow();
            //disable this script, wil set substate to none in OnDisable
            //no logic should come after this code block and after the if-elseif's here.
            gameObject.GetComponent <IceCollider>().enabled = false;
        }
        else if (substate == IceCollider.state.landedAnywhereElse)
        {
            //When cube is lands somewhere else play throw sound
            AudioSource audioSource = gameObject.AddComponent <AudioSource>();
            audioSource.clip = Resources.Load("Sounds/IceMiss2") as AudioClip;
            audioSource.Play();

            delayTimer.Start();
            substate = IceCollider.state.timerRunning;
        }
        else if (substate == IceCollider.state.timerRunning)
        {
        }
        else if (substate == IceCollider.state.delayOver)
        {
            //enable NextIceCube
            gameObject.GetComponent <NextIceCube>().enabled = true;
            gameObject.GetComponent <NextIceCube>().failThrow();
            //disable this script, wil set substate to none in OnDisable
            //no logic should come after this code block and after the if-elseif's here.
            gameObject.GetComponent <IceCollider>().enabled = false;
        }
        else if (substate == IceCollider.state.none)
        {
        }
        else if (substate == IceCollider.state.pause)
        {
            if (substate == IceCollider.state.timerRunning)
            {
                delayTimer.Enabled = false;
            }
            savedVelocity = gameObject.GetComponent <Rigidbody>().velocity;
            gameObject.GetComponent <Rigidbody>().velocity    = new Vector3(0, 0, 0);
            gameObject.GetComponent <Rigidbody>().isKinematic = true;
            gameObject.GetComponent <Rigidbody>().useGravity  = false;

            substate = IceCollider.state.paused;
        }
        else if (substate == IceCollider.state.paused)
        {
        }
        else if (substate == IceCollider.state.unpause)
        {
            substate = savedState;
            if (savedState == IceCollider.state.timerRunning)
            {
                delayTimer.Enabled = true;
            }
            gameObject.GetComponent <Rigidbody>().isKinematic = false;
            gameObject.GetComponent <Rigidbody>().useGravity  = true;
            gameObject.GetComponent <Rigidbody>().velocity    = savedVelocity;
        }
    }
Example #32
0
    public override bool checkRejected()
    {
        if (this.rejected)
        {
            return(true);
        }
        if (this.rightmost == null)
        {
            return(false);
        }
        this.rejected = this.rightmost.checkRejected();
        int total       = 1;
        int numrejected = this.rejected ? 1 : 0;

        if (this.queue != null)
        {
            foreach (nonterminalState nt in queue)
            {
                bool tmp = nt.checkRejected();
                total       += 1;
                numrejected += tmp ? 1 : 0;
            }
        }
        if (numrejected == 0)
        {
            return(false);
        }
        if (numrejected == total)
        {
            this.queue = null;
            return(true);
        }
        // at least one, but not all, rejected
        System.Diagnostics.Debug.Assert(queue != null);
        if (total - numrejected == 1)
        {
            if (this.rejected)
            {
                foreach (nonterminalState nt in this.queue)
                {
                    if (!nt.rejected)
                    {
                        this.rule      = nt.rule;
                        this.rejected  = nt.rejected;
                        this.rightmost = this.rightmost;
                        break;
                    }
                }
            }
            this.queue = null;
        }
        else
        {
            System.Diagnostics.Debug.Assert(total - numrejected > 1);
            System.Collections.Queue tmp = new System.Collections.Queue();
            foreach (nonterminalState nt in this.queue)
            {
                if (!nt.rejected)
                {
                    if (this.rejected)
                    {
                        this.rule      = nt.rule;
                        this.rejected  = nt.rejected;
                        this.rightmost = this.rightmost;
                    }
                    else
                    {
                        tmp.Enqueue(nt);
                    }
                }
            }
            this.queue = tmp;
        }
        return(false);
    }
Example #33
0
        public parceResult Start(String Input)
        {
            elements       = new SympleElement[0];
            CurrentState   = state.H;
            currentElement = -1;
            str            = Input.ToLower();

            for (int i = 0; i < str.Length; i++)
            {
                switch (CurrentState)
                {
                case state.H: if (str[i] == '#')
                    {
                        Array.Resize(ref elements,elements.Length + 1);
                        currentElement++;
                        elements[currentElement]            = new SympleElement();
                        elements[currentElement].StartIndex = i;
                        CurrentState = state.COMMENT;
                    }
                    else if (str[i] == 'a' || str[i] == 'b' || str[i] == 'c' || str[i] == 'd' || str[i] == 'e' || str[i] == 'f' || str[i] == 'g' || str[i] == 'h' || str[i] == 'i' || str[i] == 'j' || str[i] == 'k' || str[i] == 'l' || str[i] == 'm' || str[i] == 'n' || str[i] == 'o' || str[i] == 'p' || str[i] == 'q' || str[i] == 'r' || str[i] == 's' || str[i] == 't' || str[i] == 'u' || str[i] == 'v' || str[i] == 'w' || str[i] == 'x' || str[i] == 'y' || str[i] == 'z')
                    {
                        Array.Resize(ref elements,elements.Length + 1);
                        currentElement++;
                        elements[currentElement]            = new SympleElement();
                        elements[currentElement].StartIndex = i;
                        CurrentState = state.SIGNAL;
                    }
                    break;

                case state.COMMENT: if (str[i] == '#')
                    {
                        elements[currentElement].EndIndex  = i;
                        elements[currentElement].TextColor = Settings.Default.TextFieldCommentColor;
                        CurrentState = state.H;
                    }
                    break;

                case state.SIGNAL: if (str[i] != ';' && str[i] != '(' && str[i] != ')' && str[i] != '&' && str[i] != '|' && str[i] != '~' && str[i] != '#')
                    {
                    }
                    else
                    {
                        elements[currentElement].EndIndex = i - 1;
                        if (str.Substring(elements[currentElement].StartIndex,elements[currentElement].EndIndex - elements[currentElement].StartIndex + 1) == "t+1")
                        {
                            elements[currentElement].TextColor = System.Drawing.Color.Red;
                        }
                        else
                        {
                            elements[currentElement].TextColor = Settings.Default.TextFieldSignalColor;
                        }
                        if (str[i] == '#')
                        {
                            Array.Resize(ref elements,elements.Length + 1);
                            currentElement++;
                            elements[currentElement]            = new SympleElement();
                            elements[currentElement].StartIndex = i;
                            CurrentState = state.COMMENT;
                        }
                        CurrentState = state.H;
                    }
                    break;
                }
            }

            return(parceResult.PARSE_OK);
        }
Example #34
0
        public bool stepSortingNext()
        {
            switch (sortingState)
            {
            case state.initial:
            {
                massyv[insertedIndex].TxtBox.BackColor = Color.LawnGreen;
                if (insertingIndex < massyv.Length - 1)
                {
                    insertingIndex++;                                    //вважаємо перший елемент відсортованим масивом довжиною 1
                    //тому починаємо з другого елемента
                }
                else
                {
                    return(false);
                }
                //всі попередні елементи - відсортована частина списку
                insertedIndex = insertingIndex;                                      //позиція елемента, що вставляється
                massyv[insertingIndex].TxtBox.BackColor    = Color.Red;
                massyv[insertedIndex - 1].TxtBox.BackColor = Color.LawnGreen;
                sortingState = state.preWhile;
                break;
            }

            case state.preWhile:
            {
                tmp.item           = massyv[insertingIndex].item;                        //значення елемента масиву, що вставляється
                tmp.TxtBox.Left    = txtBoxLeft * (insertingIndex + 1) + txtBoxWidth * insertingIndex;
                tmp.TxtBox.Text    = tmp.item.ToString();
                tmp.TxtBox.Visible = true; massyv[insertingIndex].TxtBox.Text = "?";
                massyv[insertingIndex].TxtBox.BackColor = Color.LightGray;
                sortingState = state.inWhile;
                break;
            }

            case state.inWhile:
            {
                if ((sortingState == state.inWhile) &&                                      //поки
                    (insertedIndex > 0)                                                     //не досягли першого елемента відсортованої частини списку
                    &&                                                                      // і
                    (tmp.item < massyv[insertedIndex - 1].item)                             //елемент, що вставляється, менший, ніж черговий елемент відсортованої частини масиву
                    )
                {
                    MooveRight(insertedIndex - 1);                      //цей черговий елемент зсуваємо праворуч
                    insertedIndex--;                                    //а позиція вставки нового елемента зсувається ліворуч
                }
                else
                {
                    sortingState = state.postWhile;
                    massyv[insertedIndex].TxtBox.Text      = "ok";
                    massyv[insertedIndex].TxtBox.BackColor = Color.LightSkyBlue;
                    tmp.TxtBox.Left = txtBoxLeft * (insertedIndex + 1) + txtBoxWidth * insertedIndex;
                }
                break;
            }

            case state.postWhile:
            {
                massyv[insertedIndex].item        = tmp.item;                         //новий елемент вставляється на свою позицію
                massyv[insertedIndex].TxtBox.Text = tmp.item.ToString();
                tmp.TxtBox.Visible = false;
                //massyv[insertedIndex].TxtBox.BackColor = Color.Red;
                sortingState = state.initial;
                break;
            }
            }
            return(true);
        }
Example #35
0
 var(state, rewritingManager) = MockParser.CreateAndParseWithRewritingManager(vbe);
Example #36
0
 public byte[] FormPacketArray(header_c header_C, header_m header_M0, header_m header_M1, state state, header_m header_M2)
 {
     byte[] a1 = serialization.Serialize(header_C);
     byte[] a2 = serialization.Serialize(header_M0);
     byte[] a3 = serialization.Serialize(header_M1);
     byte[] a4 = serialization.Serialize(state);
     byte[] a5 = serialization.Serialize(header_M2);
     myArray = Combine(a1, a2, a3, a4, a5);
     return(myArray);
 }
Example #37
0
    public void Execute()
    {
        currtimer  += Time.deltaTime;
        phaseTimer += Time.deltaTime;
        // move closer to player
        moveTimer += Time.deltaTime;


        if (currstate == state.reseting)
        {
            owner.mAnimator.SetBool("isManualShout", false);

            Vector3 p = camera.ViewportToWorldPoint(new Vector3(Random.Range(0.8f, 0.95f), 0.5f, 0));// + new Vector3(0,ypos/2,0);
            newpos = new Vector3(p.x, p.y, 0);
            owner.transform.position += (newpos - owner.transform.position) * Time.deltaTime;
            moveTrolleytoDefultPos();

            playercollectionpos.Clear();
            playercollectionpos.Add(owner.player.transform.position.y);
            if (currtimer > 3.8f)
            {
                currstate = state.preDash;
                currtimer = 0.0f;
            }
        }
        else if (currstate == state.preDash)
        {
            owner.mAnimator.SetBool("isManualShout", true);
            float ypos = 0;
            for (var i = 0; i < playercollectionpos.Count; i++)
            {
                ypos += playercollectionpos[i];
            }
            ypos /= playercollectionpos.Count;
            Vector3 p = camera.ViewportToWorldPoint(new Vector3(Random.Range(0.75f, 0.95f), 0, 0));// + new Vector3(0,ypos/2,0);
            newpos = new Vector3(p.x, ypos, 0);

            moveTrolleytoFirePos();
            owner.transform.position += (newpos - owner.transform.position) * Time.deltaTime;
            if (currtimer > delayBeforeDashing)
            {
                currstate = state.Dash;
                currtimer = 0.0f;
            }
        }
        else if (currstate == state.Dash)
        {
            // dash forwards
            owner.transform.position          += Vector3.left * dashSpeed * Time.deltaTime;
            owner.myTrolley.transform.position = owner.transform.position + (Vector3.left * 3);
            Vector3 p = camera.ViewportToWorldPoint(new Vector3(Random.Range(0.08f, 0.1f), 0, 0));// + new Vector3(0,ypos/2,0);

            if (owner.transform.position.x < p.x)
            {
                currstate = state.reseting;
                currtimer = 0.0f;
            }
        }

        trackingTimer += Time.deltaTime;
        if (trackingTimer > 0.8f)
        {
            if (playercollectionpos.Count > 3)
            {
                playercollectionpos.RemoveAt(0);
            }
            playercollectionpos.Add(owner.player.transform.position.y);
            trackingTimer = 0;
        }
        if (owner.currentHealth < 0 || phaseTimer > 150.0f)
        {
            moveTrolleytoDefultPos();
            if (currstate == state.preDash)
            {
                owner.mStateMachine.ChangeState((int)BoomerAunty.BOSSATTACKS.P2ARCBOMBARDMENT);
            }
        }

        /*
         * if (!isDashing && reseting == false)
         * {
         *  // starts shooting process
         *  //isShooting = true;
         *
         *
         *  if (currtimer < delayBeforeDashing)
         *  {
         *      moveTrolleytoFirePos();
         *
         *  }
         *  else {
         *      isDashing = true;
         *      currtimer = 0;
         *  }
         *
         * }
         * else if (isDashing)
         * {
         *  // dash forwards
         *  owner.transform.position += Vector3.left * dashSpeed * Time.deltaTime;
         *  owner.myTrolley.transform.position = owner.transform.position + (Vector3.left * 3);
         *  Vector3 p = camera.ViewportToWorldPoint(new Vector3(Random.Range(0.1f, 0), 0, 0));// + new Vector3(0,ypos/2,0);
         *
         *  if (owner.transform.position.x < p.x)
         *  {
         *      isDashing = false;
         *      reseting = true;
         *  }
         * }
         * else if (moveTimer > 1.2f && reseting == false)
         * {
         *
         *  float ypos = 0;
         *  for (var i = 0; i < playercollectionpos.Count; i++)
         *  {
         *      ypos += playercollectionpos[i];
         *  }
         *  ypos /= playercollectionpos.Count;
         *  Vector3 p = camera.ViewportToWorldPoint(new Vector3(Random.Range(0.55f, 0.95f), 0, 0));// + new Vector3(0,ypos/2,0);
         *
         *  newpos = new Vector3(p.x, ypos, 0);
         *
         * }
         * else if (!isDashing && reseting == true)
         * {
         *  moveTrolleytoDefultPos();
         *  owner.transform.position += (newpos - owner.transform.position) * Time.deltaTime;
         * }
         *
         *
         *
         *
         *
         */
    }
Example #38
0
 public void SetState(state state)
 {
     GameState = state;
 }
Example #39
0
 public void DisplayPacket(state state)
 {
     DisplayPacket(state.state_base);
     DisplayPacket(state.state_ext);
 }
 public void Complete()
 {
     _state = state.complete;
 }
Example #41
0
 void Start()
 {
     currentState = state.Menu;
 }
Example #42
0
 public void ToSettings()
 {
     currentState = state.Settings;
 }
Example #43
0
        /// <summary>
        /// Разбор очередной строки
        /// </summary>
        /// <param name="InputString">Строка для разбора</param>
        /// <param name="StartState">Начальное состояние парсера</param>
        /// <returns>Результат разбора типа parceResult</returns>
        private parceResult Parse(String InputString, state StartState)
        {
            state  st1 = StartState;
            int    k   = 0;
            string tmp;

            for (int i = 0; i < InputString.Length; i++)
            {
                switch (st1)
                {
                //Буква
                case state.H: if (InputString[i] == 'a' || InputString[i] == 'b' || InputString[i] == 'c' || InputString[i] == 'd' || InputString[i] == 'e' || InputString[i] == 'f' || InputString[i] == 'g' || InputString[i] == 'h' || InputString[i] == 'i' || InputString[i] == 'j' || InputString[i] == 'k' || InputString[i] == 'l' || InputString[i] == 'm' || InputString[i] == 'n' || InputString[i] == 'o' || InputString[i] == 'p' || InputString[i] == 'q' || InputString[i] == 'r' || InputString[i] == 's' || InputString[i] == 't' || InputString[i] == 'u' || InputString[i] == 'v' || InputString[i] == 'w' || InputString[i] == 'x' || InputString[i] == 'y' || InputString[i] == 'z')
                    {
                        k   = i;
                        st1 = state.S1;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                //Буква или цифра или '(' или '='
                case state.S1: if (InputString[i] == 'a' || InputString[i] == 'b' || InputString[i] == 'c' || InputString[i] == 'd' || InputString[i] == 'e' || InputString[i] == 'f' || InputString[i] == 'g' || InputString[i] == 'h' || InputString[i] == 'i' || InputString[i] == 'j' || InputString[i] == 'k' || InputString[i] == 'l' || InputString[i] == 'm' || InputString[i] == 'n' || InputString[i] == 'o' || InputString[i] == 'p' || InputString[i] == 'q' || InputString[i] == 'r' || InputString[i] == 's' || InputString[i] == 't' || InputString[i] == 'u' || InputString[i] == 'v' || InputString[i] == 'w' || InputString[i] == 'x' || InputString[i] == 'y' || InputString[i] == 'z' || InputString[i] == '0' || InputString[i] == '1' || InputString[i] == '2' || InputString[i] == '3' || InputString[i] == '4' || InputString[i] == '5' || InputString[i] == '6' || InputString[i] == '7' || InputString[i] == '8' || InputString[i] == '9')
                    {
                        st1 = state.S1;
                    }
                    else if (InputString[i] == '(')
                    {
                        st1 = state.S2;
                        tmp = InputString.Substring(k, i - k);
                        Rules[Rules.Length - 1].AddData("State", tmp, false);
                        k = i + 1;
                    }
                    else if (InputString[i] == '=')
                    {
                        st1 = state.S7;
                        tmp = InputString.Substring(k, i - k);
                        Rules[Rules.Length - 1].AddData("State", tmp, false);
                        Rules[Rules.Length - 1].AddData("=", "=", false);
                        k = i + 1;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                case state.S2: if (InputString[i] == 't')
                    {
                        st1 = state.S3;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                case state.S3: if (InputString[i] == '+')
                    {
                        st1 = state.S4;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                case state.S4: if (InputString[i] == '1')
                    {
                        st1 = state.S5;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                case state.S5: if (InputString[i] == ')')
                    {
                        Rules[Rules.Length - 1].AddData("t+1", "(t+1)", false);
                        k   = i + 1;
                        st1 = state.S6;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                case state.S6: if (InputString[i] == '=')
                    {
                        Rules[Rules.Length - 1].AddData("=", "=", false);
                        k   = i + 1;
                        st1 = state.S7;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                //Буква или '(' или '~'
                case state.S7: if (InputString[i] == 'a' || InputString[i] == 'b' || InputString[i] == 'c' || InputString[i] == 'd' || InputString[i] == 'e' || InputString[i] == 'f' || InputString[i] == 'g' || InputString[i] == 'h' || InputString[i] == 'i' || InputString[i] == 'j' || InputString[i] == 'k' || InputString[i] == 'l' || InputString[i] == 'm' || InputString[i] == 'n' || InputString[i] == 'o' || InputString[i] == 'p' || InputString[i] == 'q' || InputString[i] == 'r' || InputString[i] == 's' || InputString[i] == 't' || InputString[i] == 'u' || InputString[i] == 'v' || InputString[i] == 'w' || InputString[i] == 'x' || InputString[i] == 'y' || InputString[i] == 'z')
                    {
                        k   = i;
                        Inv = false;
                        st1 = state.S11;
                    }
                    else if (InputString[i] == '(')
                    {
                        Inv = false;
                        Rules[Rules.Length - 1].AddData("(", "(", Inv);
                        int n = 0;
                        for (int j = i; j < InputString.Length; j++)
                        {
                            if (InputString[j] == '(')
                            {
                                n++;
                            }
                            if (InputString[j] == ')')
                            {
                                n--;
                            }
                            if (n == 0)
                            {
                                k = j;
                                break;
                            }
                        }
                        if (Parse(InputString.Substring(i + 1, k - i - 1) + ";", state.S7) == parceResult.PARCE_ERROR)
                        {
                            st1 = state.ERR;
                        }
                        i   = k - 1;
                        st1 = state.S8;
                    }
                    else if (InputString[i] == '~')
                    {
                        st1 = state.S10;
                        Inv = true;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                // ')'
                case state.S8: if (InputString[i] == ')')
                    {
                        Rules[Rules.Length - 1].AddData(")", ")", false);
                        st1 = state.S9;
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                // '&' или '|' или ';'
                case state.S9: if (InputString[i] == '&')
                    {
                        st1 = state.S7;
                        Rules[Rules.Length - 1].AddData("&", "&", false);
                    }
                    else if (InputString[i] == '|')
                    {
                        st1 = state.S7;
                        Rules[Rules.Length - 1].AddData("|", "|", false);
                    }
                    else if (InputString[i] == ';')
                    {
                        st1 = state.END;
                    }
                    break;

                // Буква или '(' или
                case state.S10: if (InputString[i] == 'a' || InputString[i] == 'b' || InputString[i] == 'c' || InputString[i] == 'd' || InputString[i] == 'e' || InputString[i] == 'f' || InputString[i] == 'g' || InputString[i] == 'h' || InputString[i] == 'i' || InputString[i] == 'j' || InputString[i] == 'k' || InputString[i] == 'l' || InputString[i] == 'm' || InputString[i] == 'n' || InputString[i] == 'o' || InputString[i] == 'p' || InputString[i] == 'q' || InputString[i] == 'r' || InputString[i] == 's' || InputString[i] == 't' || InputString[i] == 'u' || InputString[i] == 'v' || InputString[i] == 'w' || InputString[i] == 'x' || InputString[i] == 'y' || InputString[i] == 'z')
                    {
                        k   = i;
                        st1 = state.S11;
                    }
                    else if (InputString[i] == '(')
                    {
                        Inv = false;
                        Rules[Rules.Length - 1].AddData("(", "(", Inv);
                        int n = 0;
                        for (int j = i; j < InputString.Length; j++)
                        {
                            if (InputString[j] == '(')
                            {
                                n++;
                            }
                            if (InputString[j] == ')')
                            {
                                n--;
                            }
                            if (n == 0)
                            {
                                k = j;
                                break;
                            }
                        }
                        if (Parse(InputString.Substring(i + 1, k - i - 1) + ";", state.S7) == parceResult.PARCE_ERROR)
                        {
                            st1 = state.ERR;
                        }
                        i   = k - 1;
                        st1 = state.S8;
                    }
                    break;

                case state.S11: if (InputString[i] == 'a' || InputString[i] == 'b' || InputString[i] == 'c' || InputString[i] == 'd' || InputString[i] == 'e' || InputString[i] == 'f' || InputString[i] == 'g' || InputString[i] == 'h' || InputString[i] == 'i' || InputString[i] == 'j' || InputString[i] == 'k' || InputString[i] == 'l' || InputString[i] == 'm' || InputString[i] == 'n' || InputString[i] == 'o' || InputString[i] == 'p' || InputString[i] == 'q' || InputString[i] == 'r' || InputString[i] == 's' || InputString[i] == 't' || InputString[i] == 'u' || InputString[i] == 'v' || InputString[i] == 'w' || InputString[i] == 'x' || InputString[i] == 'y' || InputString[i] == 'z' || InputString[i] == '0' || InputString[i] == '1' || InputString[i] == '2' || InputString[i] == '3' || InputString[i] == '4' || InputString[i] == '5' || InputString[i] == '6' || InputString[i] == '7' || InputString[i] == '8' || InputString[i] == '9')
                    {
                        st1 = state.S11;
                    }
                    else if (InputString[i] == '&')
                    {
                        st1 = state.S7;
                        //---//

                        Rules[Rules.Length - 1].AddData("State", InputString.Substring(k, i - k), Inv);
                        Rules[Rules.Length - 1].AddData("&", "&", false);
                    }
                    else if (InputString[i] == '|')
                    {
                        st1 = state.S7;
                        //---//

                        Rules[Rules.Length - 1].AddData("State", InputString.Substring(k, i - k), Inv);
                        Rules[Rules.Length - 1].AddData("|", "|", false);
                    }
                    else if (InputString[i] == ';')
                    {
                        st1 = state.END;
                        Rules[Rules.Length - 1].AddData("State", InputString.Substring(k, i - k), Inv);
                    }
                    else
                    {
                        st1 = state.ERR;
                    }
                    break;

                case state.ERR:     //PrintText("Ошибка разбора");
                    //st1 = state.EXT;
                    break;

                case state.END:     //j++;
                    //AddRule();
                    //st1 = state.H;
                    break;

                case state.EXT:
                    break;
                }
            }
            if (st1 == state.ERR)
            {
                return(parceResult.PARCE_ERROR);
            }
            return(parceResult.PARSE_OK);
        }
Example #44
0
 public void ToMenu()
 {
     currentState = state.Menu;
 }
Example #45
0
 : DefaultReducerBehaviour(state, action);
 public void RainHell(int howManyTimes)
 {
     current         = state.Attacking;
     numberOfAttacks = howManyTimes;
 }
Example #47
0
 public void unpauseGame()
 {
     substate = IceCollider.state.unpause;
 }
Example #48
0
 public void pauseGame()
 {
     savedState = substate;
     substate   = IceCollider.state.pause;
 }
 /// <summary>
 /// Set the Container current_state - hovered/default etc.
 /// </summary>
 /// <param name="c">current_state enum value e.g. hovered</param>
 public void set_state(state c)
 {
     state = c;
 }
 public void logMouseEvent(object RawMouse, ControllerEvent mevent)
 {
     if (this.test_state == state.idle)
     {
         if (mevent.buttonflags == 0x0002)
         {
             last_released_leftclick = mevent.hDevice;
         }
     }
     else if (this.test_state == state.measure_wait)
     {
         if (mevent.buttonflags == 0x0001)
         {
             this.mlog.Add(mevent);
             this.toolStripStatusLabel1.Text = "Measuring";
             this.test_state = state.measure;
         }
     }
     else if (this.test_state == state.measure)
     {
         this.mlog.Add(mevent);
         if (mevent.buttonflags == 0x0002)
         {
             double x      = 0.0;
             double y      = 0.0;
             double ts_min = this.mlog.Events[0].ts;
             foreach (ControllerEvent e in this.mlog.Events)
             {
                 e.ts -= ts_min;
                 x    += (double)e.lastx;
                 y    += (double)e.lasty;
             }
             this.mlog.Cpi                   = Math.Round(Math.Sqrt((x * x) + (y * y)) / (10 / 2.54));
             this.textBoxCPI.Text            = this.mlog.Cpi.ToString();
             this.textBox1.Text              = "Press the Collect or Log Start button\r\n";
             this.toolStripStatusLabel1.Text = "";
             this.test_state                 = state.idle;
         }
     }
     else if (this.test_state == state.collect_wait)
     {
         if (mevent.buttonflags == 0x0001)
         {
             this.toolStripStatusLabel1.Text = "Collecting";
             this.test_state = state.collect;
         }
     }
     else if (this.test_state == state.collect)
     {
         if (mevent.buttonflags == 0x0002)
         {
             FinishCollecting();
         }
         else
         {
             AddEvent(mevent);
         }
     }
     else if (this.test_state == state.log)
     {
         AddEvent(mevent);
     }
 }
Example #51
0
 /*
  * This is a Unity Event Handler defined by MonoBehaviour.
  * It activates whenever this script is disabled, when the ice cube
  * has landed.
  */
 void OnDisable()
 {
     substate = IceCollider.state.none;
     delayTimer.Stop();
 }
Example #52
0
 await strategy.ExecuteInTransactionAsync((_dbContext, lockedJob, _logger), static async (state, ct) =>
 {
 public ActionResult StateCreateEdit(state state)
 {
     result = stateUtil.CreateEditState(state);
     return(Json(result));
 }
Example #54
0
 protected void die()
 {
     currentState = state.dead;
     gameObject.SetActive(false);
     transform.position = new Vector3(250, -250, 250);
 }
Example #55
0
 protected acceptingState(state below, string rule, state rightmost, Coordinate end, bool rejected, int serial) : base(below, rule, rightmost, end, false, serial)
 {
     System.Diagnostics.Debug.Assert(!rejected);
     this.root = (nonterminalState)rightmost;
 }
Example #56
0
 public virtual state shiftNonterm(string nonterm, int count, Coordinate end, string rule, state rightmost)
 {
     throw new System.Exception(nonterm + "== " + rule);
 }
Example #57
0
    static void Main()
    {
        bool   game = true;
        string action;
        state  currentState = state.idle;
        Random r            = new Random();
        MookID id;
        RNG    rng = new RNG();

        Enemy  enemy  = new Enemy(20, 2, (int)MookID.slime);
        Player player = new Player(30, 10, 1);

        //enemy.Examine();
        //player.Attack(enemy);
        //Console.WriteLine(enemy.ShowType() + " health: " + enemy.ShowHealth());
        //player.Attack(enemy);
        player.ShowExp();

        while (game)
        {
            switch (currentState)
            {
            case state.idle:
                Console.WriteLine("You stand in a field, taking in the breeze");
                action = Console.ReadLine();
                if (action == "fight")
                {
                    //create new random enemy <- random number variable(fix enemy parameters to only use ID and struct info)
                    id    = (MookID)r.Next(0, 5);
                    enemy = new Enemy(rng.RollStats((int)id, false), rng.RollStats((int)id, true), (int)id);
                    Console.Write("You encounter a {0}! ", id);
                    currentState = state.battle;
                }
                else if (action == "quit")
                {
                    currentState = state.quitting;
                }
                else if (action == "help" || action == "?")
                {
                    Console.WriteLine("fight/quit");
                }
                else if (action == "exp")
                {
                    player.ShowExp();
                }
                else if (action == "status")
                {
                    player.Status();
                }
                else
                {
                    Console.WriteLine("That is not a valid action");
                }
                break;

            case state.battle:
                if (enemy.GetHealth() <= 0)
                {
                    currentState = state.idle;
                }
                else
                {
                    Console.WriteLine("What will you do?");
                    action = Console.ReadLine();
                    if (action == "attack")
                    {
                        player.Attack(enemy);
                    }
                    else if (action == "examine")
                    {
                        enemy.Examine();
                    }
                    else if (action == "run")
                    {
                        Console.WriteLine("You escaped");
                        currentState = state.idle;
                    }
                    else if (action == "status" || action == "check status")
                    {
                        player.Status();
                    }
                    else if (action == "help" || action == "?")
                    {
                        Console.WriteLine("attack/examine/run/status");
                    }
                    else
                    {
                        Console.WriteLine("Invalid action");
                    }
                }
                break;

            case state.quitting:
            default:
                game = false;
                break;
            }
        }
    }
Example #58
0
 protected terminalState(state below, InputElement terminal, int serial) : base(below, serial)
 {
     this.terminal = terminal;
 }
Example #59
0
 public void ToGame()
 {
     currentState = state.Game;
 }
Example #60
0
 public cSympleParser()
 {
     elements     = new SympleElement[0];
     CurrentState = state.H;
 }