Esempio n. 1
0
    //Persegue e ataca o player se estiver a uma distancia minima, muda comportamento caso esteja muito longe do player
    private void followAndAttack()
    {
        attackBox[1].enabled = true;
        //Aumenta velocidade e persegue o player
        navMeshAgent.speed = followSpeed;
        navMeshAgent.SetDestination(player.transform.position);

        //Guarda a distancia do player
        float distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);

        //Se o player entrar em um esconderijo e estiver seguro, muda o estado para esperar e continuar a patrulha
        if (player.isSafe)
        {
            navMeshAgent.speed   = wanderSpeed;
            timeToWait           = 3f;
            myState              = stateMachine.isWaiting;
            attackBox[1].enabled = false;
        }
        //Checa se player esta muito longe ou morto, caso esteja, muda de estado para voltar a patrulhar e retoma velocidade inicial
        else if (distanceToPlayer >= disengageDistance || player.isDead)
        {
            myState              = stateMachine.isWaiting;
            timeToWait           = 2f;
            navMeshAgent.speed   = wanderSpeed;
            attackBox[1].enabled = false;
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        life               = 3;
        damageBody         = 1;
        machine            = FindObjectOfType <stateMachine>();
        playerControl      = FindObjectOfType <playerController>();
        playerPlasma       = FindObjectOfType <plasmaController>();
        anime              = GetComponent <Animator>();
        zeroEnemyTransform = GetComponent <Transform>();
        whatIsGround       = LayerMask.GetMask("Ground", "Wall", "Platform");
        groundTransform    = transform.Find("GroundCheck");
        spriteRender       = GetComponent <Renderer>();

        boxCastSize       = new Vector2(0.22f, 0.0025f);
        boxCastDirection  = new Vector2(0.0f, 0.0f);
        velocityPlayer    = new Vector2(0.0f, 0.0f);
        eulerAnglesRight  = new Vector2(0.0f, 0.0f);
        eulerAnglesLeft   = new Vector2(0.0f, 180.0f);
        zeroEnemyPosition = zeroEnemyTransform.position;

        speedPlayerX = 1.5f;
        accelerateX  = 0.0f;
        accelerateY  = 0.0f;
        sideFace     = 1.0f;
    }
Esempio n. 3
0
    void Start()
    {
        CurrentState = stateMachine.Idle;                       //Se inicia con el Idle (Default)

        anim   = GetComponent <Animator> ();
        MyBody = GetComponent <Rigidbody> ();
    }
Esempio n. 4
0
        protected string query(ref stateMachineViewModel viewModel)
        {
            string       ret      = "";
            stateMachine tmpModel = viewModel.editModel;
            var          qry      = (from a in uow.stateMachineRepository.GetAll()
                                     select a).AsQueryable();

            if (!string.IsNullOrWhiteSpace(tmpModel.stateMachineName))
            {
                qry = qry.Where(x => x.stateMachineName.Contains(
                                    tmpModel.stateMachineName));
            }
            if (!string.IsNullOrWhiteSpace(tmpModel.stateMachineDescription))
            {
                qry = qry.Where(x => x.stateMachineDescription.Contains(
                                    tmpModel.stateMachineDescription));
            }
            if (qry.Any())
            {
                viewModel.queryResult = qry.ToList();
            }
            else
            {
                viewModel.queryResult = null;
            }
            return(ret);
        }
Esempio n. 5
0
 void Update()
 {
     if (manager.turnOff && canTurnOff)
     {
         if (!navMeshAgent.isStopped)
         {
             GetComponentInChildren <Animator>().SetTrigger("morto");
         }
         navMeshAgent.isStopped = true;
         myState = stateMachine.isOff;
         attackBox[0].enabled = false;
         attackBox[1].enabled = false;
     }
     else
     {
         //Se já não estiver em modo de ataque checa se a distancia entre este objeto e o player é menor ou igual a ViewRange
         if (myState != stateMachine.isAttacking && Vector3.Distance(player.transform.position, transform.position) <= viewRange && !player.isSafe)
         {
             ////Checa se esta no chao ou nao e manipula gravidade de acordo
             //RaycastHit hit;
             //float distance = viewRange;
             //if (Physics.Raycast(transform.position, transform.TransformDirection((player.transform.position-transform.position)), out hit, distance) && hit.transform.CompareTag("Player"))
             //{
             //    Debug.DrawRay(transform.position, transform.TransformDirection((player.transform.position - transform.position)) * viewRange, Color.green);
             //    myState = stateMachine.isAttacking;
             //}
             //else
             //{
             //    Debug.DrawRay(transform.position, transform.TransformDirection((player.transform.position - transform.position)) * viewRange, Color.red);
             //}
             myState = stateMachine.isAttacking;
         }
         //Se estiver preparado para pratulhar, patrulha
         if (myState == stateMachine.isReadyToWander)
         {
             wander();
             checkProximidade();
         }
         //Se estiver patrulhando checa se ja chegou ao seu destino
         else if (myState == stateMachine.isMoving)
         {
             checkIfReachedDestination();
             checkProximidade();
         }
         //Se estiver esperando entre uma patrulha e outra, calcula o tempo que tem que esperar
         else if (myState == stateMachine.isWaiting)
         {
             waitForTime();
             checkProximidade();
         }
         //Se estiver em modo de ataque, executa comportamento de ataque
         else if (myState == stateMachine.isAttacking)
         {
             followAndAttack();
         }
     }
 }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        currentState = stateMachine.playerLobby;

        _playerSelector = this.gameObject.GetComponent <PlayerSelector>();
        _playerSelector.initPlayerSelector();

        _gameEngine = this.gameObject.AddComponent <GameEngine>();
    }
Esempio n. 7
0
    void Jump()
    {
        if (grounded)
        {
            Debug.Log(":V");
            jumping = true;

            CurrentState = stateMachine.Idle;
        }
    }
Esempio n. 8
0
 //Inicia patrulha definindo um destino randomico e válido no NavMesh
 private void wander()
 {
     //Se posição aleatória em volta da posição atual for válida
     if (RandomWanderTarget(transform.position, out navMeshPosition))
     {
         //Marca posição aleatória como destino e muda de estado
         navMeshAgent.SetDestination(navMeshPosition);
         myState = stateMachine.isMoving;
     }
 }
Esempio n. 9
0
 // Use this for initialization
 void Start()
 {
     anime            = GetComponent <Animator>();
     machine          = FindObjectOfType <stateMachine>();
     zeroEnemyControl = FindObjectOfType <zeroEnemyController>();
     playerControl    = FindObjectOfType <playerController>();
     velocityPlasma   = new Vector2(0.0f, 0.0f);
     cameraObj        = FindObjectOfType <Camera>();
     speedPlasma      = 4 * zeroEnemyControl.sideFace;
 }
Esempio n. 10
0
        private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            byte data;

            while (serialPort.BytesToRead > 0)
            {
                data = (byte)serialPort.ReadByte();
                switch (smComm)
                {
                case stateMachine.Idle:
                    if (data == 0xAA)
                    {
                        receive_header_count++;
                        smComm = stateMachine.Header;
                    }
                    break;

                case stateMachine.Header:
                    receive_header_count++;
                    if (receive_header_count == 3)
                    {
                        smComm = stateMachine.Command;
                    }
                    break;

                case stateMachine.Command:
                    frame_command = data;
                    smComm        = stateMachine.Length;
                    break;

                case stateMachine.Length:
                    frame_length        = data;
                    smComm              = stateMachine.Payload;
                    receive_length_left = frame_length;
                    break;

                case stateMachine.Payload:
                    frame_payload[frame_length - receive_length_left] = data;

                    receive_length_left--;

                    if (receive_length_left == 0)
                    {
                        parseCommand();

                        receive_header_count = 0;
                        frame_payload[0]     = 0;


                        smComm = stateMachine.Idle;
                    }
                    break;
                }
            }
        }
Esempio n. 11
0
 //Calcula quanto tempo se deve esperar e muda de estado para voltar patrulhar
 private void waitForTime()
 {
     //Conta o tempo predefinido
     timer += Time.deltaTime;
     if (timer >= timeToWait)
     {
         //Reseta o contador e muda de estado
         timer   = 0f;
         myState = stateMachine.isReadyToWander;
     }
 }
Esempio n. 12
0
 void Start()
 {
     if (enemySpawner != null)
     {
         enemySpawner.numbOfEnemies++;
     }
     rb2d              = GetComponent <Rigidbody2D>();
     state             = stateMachine.roming;
     ogMoveSpeed       = moveSpeed;
     enemySoundManager = GetComponent <EnemySoundManager>();
     player            = GameObject.FindGameObjectWithTag("Player");
 }
Esempio n. 13
0
 void Start()
 {
     attackBox    = GetComponents <BoxCollider>();
     navMeshAgent = GetComponent <NavMeshAgent>();
     manager      = Manager.current;
     //Guarda referencia para a instancia do script playerMovement
     player = playerMovement.current;
     //Define estado inicial para patrulhar
     myState = stateMachine.isReadyToWander;
     //Define velocidade inicial de patrulhamento
     navMeshAgent.speed = wanderSpeed;
     //Velocidade angular de rotação
     navMeshAgent.angularSpeed = 320;
 }
Esempio n. 14
0
    private void Start()
    {
        // Create a new instance of state machine with this.
        stateMachine = new stateMachine <sharkAI>(this);
        // Change the state to the idle state - this is the initial form.
        stateMachine.ChangeState(sharkIdleState.Instance);

        // Begin with a random speed between 0.1 and 0.2
        speed = Random.Range(0.1f, 0.2f);

        // Set hunger to be a random number between 0 and 50.
        hunger = Random.Range(0.0f, 50.0f);

        // Set energy to be a random number between 30 and 60.
        energy = Random.Range(30.0f, 60.0f);
    }
Esempio n. 15
0
    private void LookForTarget()
    {
        if (rb2d != null && health > 0)
        {
            RaycastHit2D hit2D = Physics2D.Raycast(transform.position + offset, transform.TransformDirection(rb2d.velocity),
                                                   eyes_Range, eyes_Layer);
            if (hit2D.collider != null)
            {
                if (hit2D.collider.CompareTag("Player") && !attacking && !isWiggleOn)
                {
                    // print("see");
                    hasSpotedPlayer = true;
                    RandomSec       = Random.Range(wiggleMinTime, wiggleMaxTime);
                    target          = hit2D.collider.gameObject;
                    enemySoundManager.PlayOneSound("Snore");
                    state = stateMachine.Wiggle;
                }
            }
            else if (hit2D.collider == null && !isFlying && !isWiggleOn)
            {
                if (target != null && hasSpotedPlayer)
                {
                    animator.SetBool("isAttacking", false);
                    targetLastSeen_posX = target.transform.position.x;
                    state = stateMachine.Chase;
                    return;
                }
                chaseTimer     = 0;
                moveSpeed      = Mathf.Lerp(moveSpeed, 1f, 5f * Time.deltaTime);
                animator.speed = Mathf.Lerp(moveSpeed, 1f, 5f * Time.deltaTime);
                animator.SetBool("isAttacking", false);


                state = stateMachine.roming;
                // print(animator.GetBool("isAttacking"));
            }
            else if (hit2D.collider == null && isFlying)
            {
                state = stateMachine.Flying;
            }
        }
        else
        {
            state = stateMachine.death;
        }
    }
    private IEnumerator CheckMoving()
    {
        //Ajuda per saber si l'agent es movia extreta d'aquest link: https://answers.unity.com/questions/382270/check-if-object-is-moving.html
        Vector3 startPos = agent.transform.position;

        yield return(new WaitForSeconds(.1f));

        Vector3 finalPos = agent.transform.position;

        if (startPos != finalPos)
        {
            state = stateMachine.FollowPlayer1;
        }
        else
        {
            state = stateMachine.FollowPlayer2;
        }
    }
Esempio n. 17
0
    public void Change(stateMachine nextState)
    {
        if (currentState == nextState)
        {
            return;
        }
        switch (currentState)
        {
        case stateMachine.Idle:
            m_Idle.Exit(this.gameObject);
            break;

        case stateMachine.Move:
            m_Move.Exit(this.gameObject);
            break;

        case stateMachine.Attack:
            m_Attack.Exit(this.gameObject);
            break;

        case stateMachine.Death:
            m_Death.Exit(this.gameObject);
            break;
        }
        currentState = nextState;
        switch (currentState)
        {
        case stateMachine.Idle:
            m_Idle.Enter(this.gameObject);
            break;

        case stateMachine.Move:
            m_Move.Enter(this.gameObject);
            break;

        case stateMachine.Attack:
            m_Attack.Enter(this.gameObject);
            break;

        case stateMachine.Death:
            m_Death.Enter(this.gameObject);
            break;
        }
    }
Esempio n. 18
0
    // Use this for initialization
    void Start()
    {
        anime             = GetComponent <Animator>();
        boxColliderPlasma = GetComponent <BoxCollider2D>();
        machine           = FindObjectOfType <stateMachine>();
        playerControl     = FindObjectOfType <playerController>();
        cameraObj         = FindObjectOfType <Camera>();
        anime.SetFloat("charge", playerControl.charge);
        anime.SetBool("shoting", playerControl.shot);
        speedPlasma = 4 * playerControl.sideFace * playerControl.sliceFace;

        velocityPlasma = new Vector2(0.0f, 0.0f);
        offSetPlasma2.Set(0.22f, 0);
        sizePlasma2.Set(0.44f, 0.15f);
        offSetPlasma3.Set(0.205f, 0);
        sizePlasma3.Set(0.41f, 0.23f);
        playerControl.charge  = 0.0f;
        transform.eulerAngles = playerControl.eulerTransSlice;
    }
    private void stateMachineUpdate()
    {
        switch (state)
        {
        case stateMachine.FollowPlayer1:
            Debug.Log("Player 1");
            followingPlayer1();
            break;

        case stateMachine.FollowPlayer2:
            Debug.Log("Player 2");
            followingPlayer2();
            break;

        default:
            state = stateMachine.FollowPlayer1;
            break;
        }
    }
Esempio n. 20
0
 // Update is called once per frame
 void Update()
 {
     if (health <= 0)
     {
         state = stateMachine.death;
         // Destroy(gameObject);
     }
     StateMachineControll();
     if (rb2d != null)
     {
         Debug.DrawRay(transform.position + offset, (transform.TransformDirection(rb2d.velocity)).normalized * eyes_Range, Color.red);
     }
     LookForTarget();
     if (isFlying)
     {
         leafParticle.Stop();
         state = stateMachine.Flying;
     }
     FaceTarget();
 }
Esempio n. 21
0
    void Idle()
    {
        //anim.SetBool ("Jump", false);
        jumping = false;

        if (v != 0 || h != 0)
        {
            CurrentState = stateMachine.Run;
        }

        if (Input.GetButtonDown("Jump"))
        {
            CurrentState = stateMachine.Jump;
        }

        if (Input.GetButtonDown("Fire1"))
        {
            CurrentState = stateMachine.Attack;
        }
    }
Esempio n. 22
0
    //Checa se já chegou ao destino
    private void checkIfReachedDestination()
    {
        //Pega o index atual
        int index = pathManager.getPreviousIndex();
        //Pega distancia do destino
        float destinationDistance = Vector3.Distance(transform.position, pathManager.pathPoints[index].destinationPos);

        //Checa se chegou minimamente perto do destino
        if (destinationDistance <= 1.1f)
        {
            //Caso deva esperar, pega o tempo que se deve esperar antes de iniciar nova patrulha
            if (pathManager.pathPoints[index].shouldWait)
            {
                timeToWait = pathManager.pathPoints[index].waitTime;
                myState    = stateMachine.isWaiting;
            }
            //Caso contrário inicia direto uma nova patrulha
            else
            {
                myState = stateMachine.isReadyToWander;
            }
        }
    }
Esempio n. 23
0
    void Run()
    {
        if (grounded)
        {
            anim.SetBool("IsRunning", true);
        }
        isRunning = true;
        if (v == 0 && h == 0)
        {
            isRunning = false;
            anim.SetBool("IsRunning", false);
            CurrentState = stateMachine.Idle;
        }

        if (Input.GetButtonDown("Jump"))
        {
            CurrentState = stateMachine.Jump;
        }

        if (Input.GetButtonDown("Fire1"))
        {
            CurrentState = stateMachine.Attack;
        }
    }
Esempio n. 24
0
	//not used
	public bool IsCurrentStateOnList(stateMachine[] stateGroup)
	{
		foreach(stateMachine sMachine in stateGroup)
		{
			if(sMachine == this.state)
			{
				return true;
			}
		}
		return false;
	}
Esempio n. 25
0
	void ExamineArea()
	{
		if (fovCollider.IsTouchingLayers (suspiciousLayers)) 
		{
			Collider2D[] myEnemies = Physics2D.OverlapCircleAll (transform.position, 20f, oppositionLayer);

			if(myEnemies.Length == 0)
			{
				iAmCurious = false;
			}
			else
			{
				foreach (Collider2D enemy in myEnemies) 
				{
					if(TargetInSight(enemy.gameObject)) 
					{
						//opposition is in line of sight, raise the alarm?

						if(!iAmCurious)
						{
							iAmCurious = true;
							audioSource.clip = curiousSounds[Random.Range(0, curiousSounds.Length)]; 
							audioSource.Play();
							questionMark.SetActive(true);
						}
						else
						{
							targetToShoot = enemy.transform;

							float[] weights = new float[]{33.33f, 0, 0};

							questionMark.SetActive(false);
							state = ReturnANewState(combatStates, weights);
						}
					} 
					else 
					{
						//can't directly see enemy within the cone.
						//TODO: Search pattern
					}
				}
			}
		}
		else
		{
			questionMark.SetActive(false);
		}
		timerA = 0;
	}
Esempio n. 26
0
	void RefreshChargingInfo()
	{
		aStarAI.targetPosition = targetToShoot.position;
		aStarAI.UpdatePath ();

		if(targetToShoot.GetComponent<Health>().dead == true)
		{
			//TODO: use the Possible States function 
			switchingStates = true;
			CancelInvoke();
			state = stateMachine.Patroling;
		}
	}
Esempio n. 27
0
	public stateMachine ReturnANewState(stateMachine [] possibleStates, float[] weights)
	{
		StopCoroutine("CheckAmIAnIdiot");
		iAmCurious = false;
		questionMark.SetActive(false);

		float totalWeight = 0;
		float weightCheck = 0;

		for(int i = 0; i < weights.Length; i++)
		{
			totalWeight += weights[i];
		}
		float roll = Random.Range (0, totalWeight);

		for(int i = 0; i< possibleStates.Length; i++)
		{
			weightCheck += weights[i];
			if(roll <= weightCheck)
			{
				switchingStates = true;
				CancelInvoke();
				return possibleStates[i];
			}
		}
		switchingStates = true;
		Debug.Log ("SWITCHING STATES function FAILED.");
		return stateMachine.Patroling;
	}
Esempio n. 28
0
        public ActionResult Index(stateMachineViewModel viewModel)
        {
            ActionResult          ar;
            var                   multiSelect = Request.Form[MultiSelect];
            stateMachineViewModel tmpVM;

            viewModel.clearMsg();
            ViewBag.pageStatus = TempData[PageStatus];
            if (ViewBag.pageStatus == null)
            {
                ViewBag.pageStatus = (int)PAGE_STATUS.QUERY;
            }
            stateMachine sm;

            switch (viewModel.cmd)
            {
            case "query":
                if (ViewBag.pageStatus <= (int)PAGE_STATUS.QUERY)
                {
                    viewModel.errorMsg = query(ref viewModel);
                    ar = View(viewModel);
                }
                else
                {
                    ViewBag.pageStatus   = (int)PAGE_STATUS.QUERY;
                    TempData[modelName]  = null;
                    TempData[PageStatus] = ViewBag.pageStatus;
                    ar = RedirectToAction("Index");
                    return(ar);
                }
                break;

            case "add":
            case "addNew":
                viewModel.editModel  = new stateMachine();
                ViewBag.pageStatus   = (int)PAGE_STATUS.ADD;
                TempData[modelName]  = null;
                TempData[PageStatus] = ViewBag.pageStatus;
                ar = RedirectToAction("Index");
                return(ar);

            case "update":
                sm = (from a in uow.stateMachineRepository.GetAll()
                      where a.stateMachineId
                      == new Guid(viewModel.singleSelect)
                      select a).FirstOrDefault();
                if (sm != null)
                {
                    tmpVM           = new stateMachineViewModel();
                    tmpVM.editModel = jsonUtl.decodeJson <stateMachine>(
                        jsonUtl.encodeJson(sm));
                    TempData[PageStatus] = (int)PAGE_STATUS.EDIT;
                    TempData[modelName]  = tmpVM;
                    ar = RedirectToAction("Index");
                    return(ar);
                }
                viewModel.errorMsg = $"error reading this {modelMessage}";
                ar = View(viewModel);
                break;

            case "delete":
                if (string.IsNullOrWhiteSpace(multiSelect))
                {
                    viewModel.errorMsg = $"please select {modelMessage} to delete";
                }
                else
                {
                    string[] selected = multiSelect.Split(',');
                    foreach (string stateMachineId in selected.ToList())
                    {
                        sm = (from a in uow.stateMachineRepository.GetAll()
                              where a.stateMachineId.ToString() == stateMachineId
                              select a).FirstOrDefault();
                        if (sm == null)
                        {
                            continue;
                        }
                        uow.stateMachineRepository.Delete(sm);
                    }
                    viewModel.errorMsg = uow.SaveChanges();
                    if (string.IsNullOrWhiteSpace(viewModel.errorMsg))
                    {
                        viewModel.successMsg = "successfully deleted";
                        viewModel.errorMsg   = query(ref viewModel);
                    }
                }
                ar = View(viewModel);
                break;

            case "save":
                string err = checkForm(viewModel);
                if (err.Length > 0)
                {
                    viewModel.errorMsg = err;
                    ar = View(viewModel);
                    break;
                }
                if (ViewBag.pageStatus == (int)PAGE_STATUS.ADD)
                {
                    viewModel.editModel.stateMachineId = Guid.NewGuid();
                    viewModel.editModel.createtime     = DateTime.Now;
                    stateMachine toAdd = new stateMachine();
                    toAdd = jsonUtl.decodeJson <stateMachine>(
                        jsonUtl.encodeJson(viewModel.editModel));
                    uow.stateMachineRepository.Insert(toAdd);
                    viewModel.errorMsg = uow.SaveChanges();
                    if (string.IsNullOrWhiteSpace(viewModel.errorMsg))
                    {
                        viewModel.successMsg = $"new {modelMessage} saved";
                        ViewBag.pageStatus   = (int)PAGE_STATUS.ADDSAVED;
                    }
                }
                else if (ViewBag.pageStatus == (int)PAGE_STATUS.EDIT)
                {
                    var qry = (from a in uow.stateMachineRepository.GetAll()
                               where a.stateMachineId
                               == viewModel.editModel.stateMachineId
                               select a).SingleOrDefault();
                    if (qry != null)
                    {
                        qry = reflectionUtl.assign <stateMachine,
                                                    stateMachine>(qry, viewModel.editModel);
                        uow.GetDbContext().Entry(qry).State
                            = EntityState.Modified;
                        viewModel.errorMsg = uow.SaveChanges();
                        if (string.IsNullOrWhiteSpace(viewModel.errorMsg))
                        {
                            viewModel.successMsg = $"{modelMessage} not found";
                            ViewBag.pageStatus   = (int)PAGE_STATUS.SAVED;
                        }
                    }
                    else
                    {
                        viewModel.errorMsg = $"{modelMessage} not found";
                    }
                }
                else
                {
                    viewModel.errorMsg = $"wrong page status {ViewBag.pageStatus}";
                }
                ar = View(viewModel);
                break;

            case "states":
                sm = (from a in uow.stateMachineRepository.GetAll()
                      where a.stateMachineId
                      == new Guid(viewModel.singleSelect)
                      select a).FirstOrDefault();
                if (sm != null)
                {
                    Session["stateMachineId"]   = sm.stateMachineId.ToString();
                    Session["stateMachineName"] = sm.stateMachineName + "";
                    ar = RedirectToAction("Index", "SMstate");
                    return(ar);
                }
                viewModel.errorMsg = $"error reading this {modelMessage}";
                ar = View(viewModel);
                break;

            case "events":
                sm = (from a in uow.stateMachineRepository.GetAll()
                      where a.stateMachineId
                      == new Guid(viewModel.singleSelect)
                      select a).FirstOrDefault();
                if (sm != null)
                {
                    Session["stateMachineId"]   = sm.stateMachineId.ToString();
                    Session["stateMachineName"] = sm.stateMachineName + "";
                    ar = RedirectToAction("Index", "SMevent");
                    return(ar);
                }
                viewModel.errorMsg = $"error reading this {modelMessage}";
                ar = View(viewModel);
                break;

            default:
                ar = View(viewModel);
                break;
            }
            TempData[modelName]  = viewModel;
            TempData[PageStatus] = ViewBag.pageStatus;
            return(ar);
        }
Esempio n. 29
0
 // Use this for initialization
 void Start()
 {
     //nodes = GameObject.FindGameObjectsWithTag("Node");
     FSM = new stateMachine();
 }
Esempio n. 30
0
 // Update is called once per frame
 void Update()
 {
     currentState = checkChangeState();
     updateState();
 }
Esempio n. 31
0
 public void SwitchState(stateMachine nextState)
 {
     lastState    = currentState;
     currentState = nextState;
 }
Esempio n. 32
0
 public stateMachineViewModel()
 {
     editModel   = new stateMachine();
     queryResult = new List <stateMachine>();
 }
Esempio n. 33
0
 // Use this for initialization
 void Start()
 {
     //nodes = GameObject.FindGameObjectsWithTag("Node");
     FSM = new stateMachine();
 }
Esempio n. 34
0
        public void MainLoop()
        {
            List <string> npcInput = null;

            XmlDocument pointerFirstname = new XmlDocument();
            XmlDocument pointerLastname  = new XmlDocument();

            while (state == stateMachine.startState)//takes & validates input of name sex & origin
            {
                Console.WriteLine("");
                Console.WriteLine("State sex & origin of name (E.G. 'm,k,k' or 'f,s,z')");
                String npcConsoleInput = Console.ReadLine();
                npcInput = npcConsoleInput.Split(',').ToList();

                if (InputValidation(npcInput) == true)
                {
                    if (npcInput[1].Equals("k"))
                    {
                        pointerFirstname = firstnamesKannamereXML;
                    }
                    else if (npcInput[1].Equals("h"))
                    {
                        pointerFirstname = firstnamesHerzamarkXML;
                    }
                    else if (npcInput[1].Equals("p"))
                    {
                        pointerFirstname = firstnamesStavroXML;
                    }
                    else if (npcInput[1].Equals("z"))
                    {
                        pointerFirstname = firstnamesZolbonneXML;
                    }
                    else if (npcInput[1].Equals("u"))
                    {
                        pointerFirstname = firstnamesUnitedCoast;
                    }
                    else if (npcInput[1].Equals("dr"))
                    {
                        pointerFirstname = dragonbornFirstnamesXML;
                    }
                    else if (npcInput[1].Equals("dw"))
                    {
                        pointerFirstname = dwarvenFirstnamesXML;
                    }
                    else if (npcInput[1].Equals("el"))
                    {
                        pointerFirstname = elvishFirstnamesXML;
                    }
                    else if (npcInput[1].Equals("gn"))
                    {
                        pointerFirstname = gnomishFirstnamesXML;
                    }
                    else if (npcInput[1].Equals("ha"))
                    {
                        pointerFirstname = halflingFirstnamesXML;
                    }
                    else if (npcInput[1].Equals("or"))
                    {
                        pointerFirstname = orcishFirstnamesXML;
                    }

                    if (npcInput[2].Equals("k"))
                    {
                        pointerLastname = lastnamesKannamereXML;
                    }
                    else if (npcInput[2].Equals("h"))
                    {
                        pointerLastname = lastnamesHerzamarkXML;
                    }
                    else if (npcInput[2].Equals("p"))
                    {
                        pointerLastname = lastnamesStavroXML;
                    }
                    else if (npcInput[2].Equals("z"))
                    {
                        pointerLastname = lastnamesZolbonneXML;
                    }
                    else if (npcInput[2].Equals("u"))
                    {
                        pointerLastname = lastnamesUnitedCoast;
                    }
                    else if (npcInput[2].Equals("dr"))
                    {
                        pointerLastname = dragonbornLastnamesXML;
                    }
                    else if (npcInput[2].Equals("dw"))
                    {
                        pointerLastname = dwarvenLastnamesXML;
                    }
                    else if (npcInput[2].Equals("el"))
                    {
                        pointerLastname = elvishLastnamesXML;
                    }
                    else if (npcInput[2].Equals("gn"))
                    {
                        pointerLastname = gnomishLastnamesXML;
                    }
                    else if (npcInput[2].Equals("ha"))
                    {
                        pointerLastname = halflingLastnamesXML;
                    }
                    //else if (npcInput[2].Equals("or")) { Console.WriteLine("No orcish last names"); }

                    //stepCount = 1;
                    state = stateMachine.inputNameState;
                }
            }

            while (state == stateMachine.inputNameState)
            {
                while (PickFirstname(pointerFirstname, npcInput[0]) == false)
                { /*PickFirstname(pointerFirstname, npcInput[0]);*/
                } //KEEP EMPTY, otherwise f(x) runs twice and program has to find 2 available names in a row.

                while (PickLastname(pointerLastname) == false) /*PickLastname(pointerLastname);*/ } {
                //KEEP EMPTY, same as above while loop.

                //stepCount = 2;
                state = stateMachine.inputSaveState;
        }

        while (state == stateMachine.inputSaveState)     //asks to save & acts accordingly
        {
            Console.WriteLine("Change names' ''used before'' status? (yy, yn, ny, nn)");
            String saveInput = Console.ReadLine();

            if (SaveChangeToUsedBeforeFlag(pointerFirstname, pointerLastname, saveInput, npcInput) == true)
            {
                state = stateMachine.startState;
            }
        }
    }
Esempio n. 35
0
 // Use this for initialization
 void Start()
 {
     m_Idle.Enter(this.gameObject);
     currentState = stateMachine.Idle;
     rigidbady    = this.GetComponent <Rigidbody>();
 }