Esempio n. 1
0
 public void Strike(Vector2 pos, float waittime, float yValue)
 {
     mStrikePos = pos;
     mState = states.MOVING;
     mStrikeTime = waittime;
     mYValue = yValue;
 }
Esempio n. 2
0
    void checkInput()
    {
        if (Input.GetMouseButton(0))
        {
            RaycastHit hit;
            Ray ray = (Camera.main.ScreenPointToRay(Input.mousePosition));

            if (Physics.Raycast(ray, out hit))
            {
        //				Debug.Log("Hit: " + hit.transform.name);
                if (hit.transform.name == "Ground")
                {
                    movePoint = new Vector3(hit.point.x, 0, hit.point.z);
                    transform.LookAt(movePoint);
                    Debug.DrawLine(Camera.main.transform.position, hit.point);
                    currentState = states.Moving;
                }
            }
        }
        if (Input.GetMouseButton(1)) {
            currentState = states.Attacking;
        } else if (Input.GetMouseButtonUp(1)) {
            currentState = states.Idle;
        }
    }
Esempio n. 3
0
 public void ChumboFire()
 {
     state = states.CHUMBO_FIRE;
     animator.Play("pungaFireMegachumbo", 0, 0);
     Invoke("EndAnimation", 0.5f);
     Events.OnSoundFX("megachumbo");
 }
Esempio n. 4
0
	// Use this for initialization
	void Start () {
		moveDirection = states.STOP;

		player = GameObject.FindGameObjectWithTag("Player");
		playerState = player.gameObject.GetComponent<Move> ();
	
	}
Esempio n. 5
0
	void Update () {
		
	
		if (playerState.facing == Move.faceStates.FACERIGHT && isHit && rightMoveable)
		{
			Yspeed = 0;
			Xspeed = speed;
			isHit = false;
			moveDirection = states.RIGHT;
		}
		if (playerState.facing == Move.faceStates.FACEUP && isHit && upMoveable)
		{
			Yspeed = speed;
			Xspeed = 0;
			isHit = false;
			moveDirection = states.UP;
		}
		if (playerState.facing == Move.faceStates.FACELEFT && isHit && leftMoveable)
		{
			Yspeed = 0;
			Xspeed = -speed;
			isHit = false;
			moveDirection = states.LEFT;
		}
		if (playerState.facing == Move.faceStates.FACEDOWN && isHit && downMoveable)
		{
			Yspeed = -speed;
			Xspeed = 0;
			isHit = false;
			moveDirection = states.DOWN;
		}
		isHit = false;
		transform.position = new Vector2 (transform.position.x +Xspeed*Time.deltaTime, transform.position.y +Yspeed*Time.deltaTime);

	}
Esempio n. 6
0
 public override void Enemy_Init(EnemySettings settings, int laneId)
 {
     anim.Play("copShieldIdle");
     state = states.IDLE;
     GetComponent<BoxCollider2D>().enabled = true;
     heads.sprite = Data.Instance.enemiesManager.GetRandomHead();
 }
    // Update is called once per frame
    void Update()
    {
        if(state == states.chase)
        {
            if (transform.position.x < Globals.heroPos.x)
            {
                transform.Translate (Vector3.right * Time.deltaTime * moveSpeed );
            }
            else if (transform.position.x > Globals.heroPos.x)
            {
                transform.Translate (Vector3.left * Time.deltaTime * moveSpeed );
            }
        }
        else if(state == states.patrolLeft)
        {
            transform.Translate (Vector3.left * Time.deltaTime * moveSpeed );

            if(transform.position.x < minPosX)
            {
                state = states.patrolRight;
            }
        }
        else if(state == states.patrolRight)
        {
            transform.Translate (Vector3.right * Time.deltaTime * moveSpeed );

            if(transform.position.x > maxPosX)
            {
                state = states.patrolLeft;
            }
        }
    }
Esempio n. 8
0
    private void Idling()
    {
        if( Input.GetButton("DOWN") ){
            state = states.CROUCHING;
        }
        if(
            Input.GetButton("UP") && !Input.GetButton("RIGHT") ||
            Input.GetButton("UP") && !Input.GetButton("LEFT")
        ){
            state = states.JUMPING_UP;
        }
        if( Input.GetButton("UP") ){
            state = states.JUMPING_UP;
        }
        if( Input.GetButton("RIGHT") ){
            state = states.MOVING_RIGHT;
        }
        if( Input.GetButton("LEFT") ){
            state = states.MOVING_LEFT;
        }

        if(
            Input.GetButton("HK") ||
            Input.GetButton("LK") ||
            Input.GetButton("HP") ||
            Input.GetButton("LP")
        ){
            smm.isStandardAttacking = true; // Do move?
            state = states.ATTACKING;
        }
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        state = states.IDLE;
        print (states.NUM_STATES + " : "+ MAX_STATES);

        Player = GameObject.FindGameObjectWithTag("Player").transform;
    }
Esempio n. 10
0
 public StateObject(DataHistoryRow passeddata)
 {
     _callLevel = 0;
     _isOperation = false;
     _data = passeddata;
     _currentState = states.OT;
 }
Esempio n. 11
0
        public Character(string textureName, Vector2 position, ContentManager content, int frameCount)
        {
            mContent = content;
            mTextureName = textureName;
            mPosition = position;
            mAge = age.BABY;
            mStates = states.SPAWNING;
            mSpeed = new Vector2(1.0f, 0.25f);
            //mSpeed = new Vector2(0, 0);

            mSprite = new AnimatedSprite();
            //mSprite.Load(mContent, "AnimatedSprites/" + mTextureName, frameCount, 30, 149, 139, false);
            mSprite.Load(mContent, "AnimatedSprites/" + mTextureName, frameCount, 0.125f, 128, 128, false);

            bSphere = new BoundingSphere(new Vector3(position.X + mSprite.getWidth() / 2, position.Y + mSprite.getHeight() / 2, 0), mSprite.getWidth() / 2);
            distance = 10000;
            destination = Vector2.Zero;
            timeEating = 2.0f;

            timeOnFire = 0.5f;

            respawnRate = 3.0f;
            remove = false;
            multipleOfTwo = false;
            hacktex = Class1.CreateCircle((int)mSprite.getWidth() / 2, Color.Yellow);

            timespawning = 2.0f;
        }
Esempio n. 12
0
 public bool isState(states st)
 {
     if (state == st)
         return true;
     else
         return false;
 }
Esempio n. 13
0
 public void PlayerInsideNest()
 {
     if (state != states.Angry) {
         state = states.Chasing;
         alert = true;
     }
 }
Esempio n. 14
0
 public Item(string name, Vector2 position, ContentManager content)
 {
     mContent = content;
     mTextureName = name;
     mPosition = position;
     mState = states.DRAW;
     cupcake = mContent.Load<Texture2D>("Items/cupcake");
 }
Esempio n. 15
0
 public override void OnExplote()
 {
     if (state == states.CRASHED) return;
     state = states.CRASHED;
     anim.Play("crashed");
     GetComponent<BoxCollider2D>().enabled = false;
     Events.OnAddExplotion(laneId, (int)transform.localPosition.x);
 }
Esempio n. 16
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player" && playerCtrl.currentState != playerControl.states.hiding && currentState != states.movingToBad && currentState != states.sleeping) {
         findWay(pointsOfInterests[0]);
         currentState = states.movingToBad;
         scaryLevel = 0;
     }
 }
Esempio n. 17
0
    public override void OnExplote()
    {
        if (state == states.CRASHED) return;
        state = states.CRASHED;

        Events.OnAddExplotion(laneId, (int)transform.localPosition.x);

        Pool();
    }
Esempio n. 18
0
 public void OnHeroDash()
 {
     if (Game.Instance.state != Game.states.PLAYING) return;
     if (state == states.DASH) return;
     if (state == states.CRASH) return;
     state = states.DASH;
     animator.SetBool(state.ToString(), true);
     animator.Play("pungaDash", 0, 0);
 }
Esempio n. 19
0
 void Attack(int selected)
 {
     print ("ATTACKING");
     Item attackweapon = Weapon.GetComponent<Item>();
     attackweapon.Lethal = true;
     attackweapon.Range.enabled = true;
     attacking = attackweapon.AttackSpeed;
     State = states.Attacking;
 }
Esempio n. 20
0
 public Weapon(ContentManager cm, GraphicsDeviceManager graphics)
 {
     mCharManager = CharacterManager.GetInstance(cm, graphics);
     mTexture = null;
     mScale = new Vector2(1.0f, 0.0f);
     mStrikeTime = 0;
     mStrikePos = Vector2.Zero;
     mState = states.NORMAL;
     mOnScreenTime = 0.5f;
 }
Esempio n. 21
0
 public Weapon(string textureName, ContentManager cm, GraphicsDeviceManager graphics)
 {
     mCharManager = CharacterManager.GetInstance(cm, graphics);
     mTexture = cm.Load<Texture2D>("Weapons/" + textureName);
     mScale = new Vector2(1.0f, 0.0f);
     mStrikeTime = 0;
     mStrikePos = Vector2.Zero;
     mState = states.NORMAL;
     mOnScreenTime = 0.5f;
 }
Esempio n. 22
0
 public void PopUp()
 {
     if(state == states.CLOSED)
         state = states.RISING;
     //move up
     //disable rest of UI
     //grow select thing
     //fill select thing with bosses
     //change text to OK
 }
Esempio n. 23
0
 public void Okay()
 {
     if(state == states.OPEN){
         open = false;
         state = states.SHRINKING;
     }
     //shrink select thing
     //move down
     //reenable UI
 }
Esempio n. 24
0
    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyUp(KeyCode.F1))
        {
            this.state+=1;
        }//if

        //Gravity
        //transform.position += Physics.gravity;

        switch(state)
        {
        case states.IDLE:
            animation.CrossFade("idle");

            transform.LookAt(Player);

            if(Vector3.Distance(transform.position,Player.position) >= 10.0f)
            {
                state = states.APPROACH;
            }//if
            break;
        case states.ALERT:
            animation.CrossFade("waitingforbattle");
            break;
        case states.APPROACH:
            animation.CrossFade("run");
            //float oldY = transform.position.y;
            transform.position += transform.forward*moveSpeed*Time.deltaTime;

                //animation.CrossFade("run");
                if(Vector3.Distance(transform.position,Player.position) <= 0.5f)
                {
                     state = states.ATTACK;
                }//if
            break;
        case states.TELEGRAPH:
            animation.Blend("attack");
            break;
        case states.ATTACK:
            animation.CrossFade("attack");
            break;
        case states.GET_HIT:
            animation.CrossFade("gethit");
            break;
        case states.DIE:
            animation.CrossFade("die");
            break;
        case states.DANCE:
            animation.CrossFade("dance");
            break;
        }
    }
Esempio n. 25
0
 void GetNeedState(int i)
 {
     if (i == 0)
         State = states.Eat;
     else if (i == 1)
         State = states.Smoke;
     else if (i == 2)
         State = states.Bathroom;
     else if (i == 3)
         State = states.Drink;
     Wait = 0;
 }
Esempio n. 26
0
    public void setNewPos(Vector3 pos)
    {
        requestedPos = new Vector3(
            pos.x,
            myTransform.position.y,
            pos.z);

        if (Vector3.Distance(myTransform.position, requestedPos) > 2)
        {
            state = states.move;
        }
    }
    void Start()
    {
        RUIManager.instance.registerRUISpriteButton(gameObject);

        sp = transform.GetComponent<exSprite> ();
        currentState = states.Normal;
        int idx = sp.index;
        NormalState = sp.atlas.elements [idx].name;

        if (ClickState == null || ClickState == "") {
            Debug.LogWarning ("Click State NOT SET: " + name);
        }
    }
Esempio n. 28
0
        /// <summary>GestureHandler Constructor with pointless XML Summary</summary>
        /// <param name="_mainWindow">MainWindow object</param>
        /// <param name="jointBufferSize">How many frames should be in the jointBuffer? 30 is good.</param>
        public GestureHandler(MainWindow _mainWindow, int jointBufferSize)
        {
            mainWindow = _mainWindow;
            //Added override by Ravi
            //isGesturesEnabled = true;
            state = states.stationary;

            JointBufferSize = jointBufferSize;
            JointHistory = new List<List<Joint>>();
            try { // Build initial joint history buffer
                for (int i = 0; i < (int)JointID.Count; i++)
                    JointHistory.Add(new List<Joint>()); }
            catch (Exception ex) { onMessage(ex.ToString()); }
        }
Esempio n. 29
0
 void OnGamePaused(bool paused)
 {
     if (paused)
     {
         lastState = state;
         Time.timeScale = 0;
         state = states.PAUSED;
     }
     else
     {
         state = lastState;
         Time.timeScale = 1;
     }
 }
Esempio n. 30
0
File: iShip.cs Progetto: gornikp/ZTP
        public void shootIt()    //metoda aktualizująca przesyłąnie co się zmieniło w obiekcie Move (metoda uaktualnij)
        {

            if (contain())
            {
                remove();
                if (Coords.Count == 0)
                    state_ = states.dead;
                else
                    state_ = states.hit;
            }
            else
                state_ = states.miss;

        }
Esempio n. 31
0
    void Start()
    {
        state  = states.PLAYING;
        moveTo = GetComponent <MoveTo> ();
        anim   = GetComponent <CharacterAnimations> ();

        Events.OnFloorClicked                  += OnFloorClicked;
        Events.CloseFruitNinja                 += CloseFruitNinja;
        Events.OnCharacterStopWalking          += OnCharacterStopWalking;
        Events.OnCharacterHitInteractiveObject += OnCharacterHitInteractiveObject;
        Events.OnIngameUIPopup                 += OnIngameUIPopup;
        //Events.OnMinigameDone += OnMinigameDone;
        transform.localPosition = Data.Instance.userData.lastPosition;

        if (Data.Instance.lastLevel == "Pociones" ||
            Data.Instance.lastLevel == "Combinatorias" ||
            Data.Instance.lastLevel == "Grilla" ||
            Data.Instance.lastLevel == "Figuras")
        {
            OnMinigameDone();
        }
    }
 //When the AI is in the flee state it will run away from the player avoiding obstcales.If not in flee state it will be in patrol state.
 void stateFlee()
 {
     if (controller.timeInFlee <= controller.timeToFlee)
     {
         // AI will flee from the player and avoid obsctales while its fleeing.
         Vector3 directionToFlee = -(GameManager.instance.players[0].transform.position - transform.position);
         if (controller.canMove())
         {
             controller.obstacleAvoidanceMove();
             controller.motor.rotateTowards(directionToFlee);
         }
         controller.obstacleAvoidanceMove();
         //AI will contuine to flee if they sense the player.
         controller.timeInFlee += Time.deltaTime;
     }
     else
     {
         //If AI is no longer fleeing then it will go into patrol state.
         controller.timeInFlee = 0;
         currentState          = states.patrol;
     }
 }
    public void SetState(states _state)
    {
        this.state = _state;
        switch (state)
        {
        case states.INSERT_COIN:
            dead.SetActive(false);
            insertCoin.SetActive(true);
            break;

        case states.DEAD:
            fillAmount = 0;
            dead.SetActive(true);
            insertCoin.SetActive(false);
            break;

        case states.PLAYING:
            dead.SetActive(false);
            insertCoin.SetActive(false);
            break;
        }
    }
Esempio n. 34
0
    public void PlayToggle()
    {
        if (state != states.PLAYING)
        {
            state = states.PLAYING;
        }
        else
        {
            state = states.STOPPED;
        }

        if (state == states.PLAYING)
        {
            //  timer -= 0.1f;

            Events.OnPlaying(true);
        }
        else
        {
            Events.OnPlaying(false);
        }
    }
Esempio n. 35
0
 //When this AI flees it will get as far as it can from the player and once the player is out of sight and is not heard it will go into chase state.
 void stateFlee()
 {
     if (controller.timeInFlee <= controller.timeToFlee)
     {
         // The AI runs away from the player.
         Vector3 directionToFlee = -(GameManager.instance.players[0].transform.position - transform.position);
         if (controller.canMove())
         {
             controller.obstacleAvoidanceMove();
             controller.motor.rotateTowards(directionToFlee);
         }
         //The AI avoids obstcales while fleeing and if the player is still within rnge then they will contunie to flee.
         controller.obstacleAvoidanceMove();
         controller.timeInFlee += Time.deltaTime;
     }
     else
     {
         //When the AI is no longer fleeing it will go back to its chase state.
         controller.timeInFlee = 0;
         currentState          = states.chase;
     }
 }
Esempio n. 36
0
File: Main.cs Progetto: TaJL/SvsB
    void Start()
    {
        player     = GameObject.FindGameObjectsWithTag("Player")[0].GetComponent <Player>();
        mainCamera = Camera.main.GetComponent <MainCamera>();
        goal       = GameObject.FindGameObjectsWithTag("Goal")[0];
        levelText  = GameObject.FindGameObjectsWithTag("LevelText")[0].GetComponent <Text>();
        title      = GameObject.FindGameObjectsWithTag("Title")[0].GetComponent <Text>();

        player.VerSpeed     = player_ver_speed;
        mainCamera.VerSpeed = player_ver_speed;

        baseHp = BaseHp;
        if (hpLastLevel == 0)
        {
            hpLastLevel = baseHp;
        }

        state = states.Ready;
        NextState();

        EventManager.StartListening(EVENT_GAME_OVER, SetStateGameOver);
    }
Esempio n. 37
0
    void stateFlee()
    {
        float distanceFromTarget = Vector3.Distance(transform.position, GameManager.instance.players[0].transform.position);

        if (controller.distanceToMaintain >= distanceFromTarget)
        {
            // run away from player
            Vector3 directionToFlee = -(GameManager.instance.players[0].transform.position - transform.position);
            if (controller.canMove())
            {
                controller.obstacleAvoidanceMove();
                controller.motor.rotateTowards(directionToFlee);
            }
            controller.obstacleAvoidanceMove();
            // increase fleeing time
        }
        else
        {
            //back to chase state
            currentState = states.chase;
        }
    }
    public void OnFloor()
    {
        if (state == states.DEAD)
        {
            return;
        }
        if (state == states.IDLE)
        {
            return;
        }


        jumpsNumber = 0;
        state       = states.RUN;

        Data.Instance.events.OnSoundFX("floor", player.id);

        Data.Instance.events.OnMadRollerFX(MadRollersSFX.types.TOUCH_GROUND, player.id);

        madRoller.Play("floorHit");
        Invoke("OnFloorDone", 0.5f);
    }
    public void SuperJump(float _superJumpHeight, bool isDoubleJump = false)
    {
        float velocityY = rb.velocity.y;

        if (velocityY < 10)
        {
            OnAvatarJump();
            velocityY   = Mathf.Abs(velocityY);
            rb.velocity = Vector3.zero;

            if (velocityY > 4)
            {
                velocityY = 4;
            }

            velocityY /= 8;

            if (velocityY < 1 || !isDoubleJump)
            {
                velocityY = 1;
            }

            rb.AddForce(new Vector3(0, (_superJumpHeight) - (jumpHeight / 10), 0) * velocityY, ForceMode.Impulse);

            Data.Instance.events.OnMadRollerFX(MadRollersSFX.types.DOUBLE_JUMP, player.id);

            int rand = Random.Range(0, 10);
            if (rand < 5)
            {
                madRoller.Play("doubleJump");
            }
            else
            {
                madRoller.Play("doubleJump2");
            }

            state = states.DOUBLEJUMP;
        }
    }
Esempio n. 40
0
 void WaitForPlayer()
 {
     //wait for player movement
     if (instructionScreen.sprite == instructions[0])
     {
         if (playerMovement.velocity.x != 0 || playerMovement.velocity.y != 0)
         {
             playerBark.enabled = true;
             NewInstruction(1);
         }
     }
     //wait for bark
     else if (instructionScreen.sprite == instructions[1])
     {
         if (playerBark.grenadeCooldown > 0)
         {
             transform.localScale = new Vector3(1, 1, 1);
             blindGuyAI.enabled   = true;
             myState = states.normal;
         }
     }
 }
    public void ResetPositions(float offsetBack)
    {
        if (state == states.FIRST_PART)
        {
            return;
        }

        foreach (CharacterBehavior cb in characters)
        {
            cb.GetComponent <Rigidbody> ().velocity = Vector3.zero;
            Vector3 pos = cb.transform.localPosition;
            pos.y = 16;
            cb.transform.localPosition = pos;
        }

        state = states.FIRST_PART;
        /////////////////////Invoke("AddAutomaticPlayersToAll", 0.5f);
        distance = -(Data.Instance.versusManager.GetArea().z_length + offsetBack);
        camera_team_1.ResetVersusPosition();
        camera_team_2.ResetVersusPosition();
        AddPowerUps();
    }
Esempio n. 42
0
    void stateChase()
    {
        // hold ground and shoot at the target
        Vector3 targetLocation = GameManager.instance.players[0].transform.position - transform.position;

        // rotate to target position
        controller.motor.rotateTowards(targetLocation);
        // keep firing
        controller.motor.ShootMissile();


        // go into flee state if health is below 50%
        if (controller.data.healthCurrent <= (controller.data.healthMax / 2)) // TODO: Probably change to a percentage threshhold, but we will leave at 1/2 for now
        {
            thisState = states.Flee;
        }
        //resume patrolling if can not see target or hear target.
        if (!controller.canHearTarget() && !controller.canSeeTarget())
        {
            thisState = states.Patrol;
        }
    }
Esempio n. 43
0
    /// <summary>
    /// Sent when another object enters a trigger collider attached to this
    /// object (2D physics only).
    /// </summary>
    /// <param name="other">The other Collider2D involved in this collision.</param>
    void OnTriggerEnter2D(Collider2D other)
    {
        if (canMove)
        {
            if (other.tag == "Teleport")
            {
                if (Random.Range(0, 100000) > 50000 && isRun)
                {
                    isRun = false;
                    detectCollider.enabled = false;
                    other.GetComponent <Teleport>().ChangePlace(this);
                }
            }
            else if (other.tag == "HidePlace")
            {
                int offset = 0;
                if (!SeePlayerBackward(8f) && !SeePlayerForward(8f))
                {
                    offset = 25000;
                }

                if (Random.Range(0, 100000) > (90000 - offset) && isRun && !other.GetComponent <HidePlace>().kid)
                {
                    if (SeePlayerBackward(3.5f) && SeePlayerForward(3.5f))
                    {
                        hidePlayerSee = true;
                    }

                    isRun               = false;
                    currentState        = states.HIDE;
                    countTime           = Random.Range(10f, 15f);
                    sprRenderer.enabled = false;
                    hidePlace           = other.GetComponent <HidePlace>();
                    hidePlace.Hide(this);
                }
            }
        }
    }
Esempio n. 44
0
    void OnTriggerEnter(Collider col)
    {
        Npc guest = col.gameObject.GetComponent <Npc>();

        if (guest != null && mingler == null && SearchingforArea == null)
        {
            float distance = Vector3.Distance(guest.transform.position, transform.position);
            if (distance > 0.5f)
            {
                if (guest.State == states.Afraid)
                {
                    State = states.Afraid;
                }
                else if (guest.State == states.Idle)
                {
                    mingler       = guest;
                    guest.mingler = this;
                    guest.State   = states.Talking;
                    State         = states.Talking;
                }
            }
            else
            {
                direction = Move[Random.Range(0, Move.Length)];
                Vector3 move     = direction + new Vector3(direction.x * Random.Range(1f, 20f), direction.y * Random.Range(1f, 12f), -0.1f);
                bool    walkable = (Physics.CheckSphere(move, 0.5f, layermask));
                if (walkable)
                {
                    State = states.Walk;
                    Unit.MoveTo(move);
                }
                else
                {
                    counter = SetCounter;
                }
            }
        }
    }
Esempio n. 45
0
    // Update is called once per frame
    void Update()
    {
        c  = new Vector2(Head.gameObject.transform.position.x, Head.gameObject.transform.position.z);
        rv = new Vector2(RK.transform.position.x, RK.transform.position.z);
        lv = new Vector2(LK.transform.position.x, LK.transform.position.z);

        dist = Vector3.Distance(rv, lv) + .3f;
        if ((state == states.standing) && (dist < Vector2.Distance(rv, c) && dist < Vector2.Distance(lv, c)))
        {
            state = states.falling;
        }
        else if ((state == states.falling || state == states.bounced) && (dist >= Vector2.Distance(rv, c) || dist >= Vector2.Distance(lv, c)))
        {
            state = states.standing;
        }
        if ((state == states.standing) && (RK.position.y - ground.position.y > 1.25f && LK.position.y - ground.position.y > 1.25f))
        {
            state = states.falling;
        }
        else if ((state == states.falling) && (RK.position.y - ground.position.y <= 1.25f && LK.position.y - ground.position.y <= 1.25f))
        {
            state = states.standing;
        }


        if (state == states.fallen)
        {
            Head.AddForce(0f, 27.5f, 0f, ForceMode.VelocityChange);
            Spine.AddForce(0f, 27.5f, 0f, ForceMode.VelocityChange);
            state = states.bounced;
        }
        else if (state == states.standing)
        {
            Head.AddForce(0f, 2.25f, 0f, ForceMode.VelocityChange);
        }

        Debug.Log(state);
    }
Esempio n. 46
0
        /// <summary>
        /// Dialog event loop
        /// </summary>
        /// <param name="msg"></param>
        public override void HandleMessage(string msg)
        {
            msg = msg.Trim();
            if (string.IsNullOrWhiteSpace(msg) && status != states.WaitForContinue)
            {
                return;
            }
            switch (status)
            {
            case states.WaitForOldPassword:
                if (user.CheckPassword(msg))
                {
                    LnWrite(catalog.GetString("New password") + ": ");
                    status = states.WaitForNewPassword;
                }
                else
                {
                    LnWrite(catalog.GetString("Password incorrect. Try again."));
                    LnWrite(catalog.GetString("Old password") + ": ");
                }
                break;

            case states.WaitForNewPassword:
                handleWaitForNewPassword(msg);
                break;

            case states.WaitForConfirm:
                handleWaitForConfirm(msg);
                break;

            case states.WaitForContinue:
                ShowNext();
                break;

            default:
                break;
            }
        }
Esempio n. 47
0
    void updateRoom(Message <Room> msg)
    {
        if (!msg.IsError)
        {
            printOutputLine("Received room update notification");
            Room room = msg.Data;

            if (currentState == states.IN_EMPTY_ROOM)
            {
                // Check to see if this update is another user joining
                foreach (User element in room.Users)
                {
                    if (element.ID != localUser.ID)
                    {
                        remoteUser   = element;
                        currentState = states.IN_FULL_ROOM;
                    }
                }
            }
            else
            {
                // Check to see if this update is another user leaving
                if (room.Users.Count == 1)
                {
                    printOutputLine("User ID: " + remoteUser.ID.ToString() + "has left");
                    remoteUser   = null;
                    currentState = states.IN_EMPTY_ROOM;
                }
            }
        }
        else
        {
            printOutputLine("Received room update error");

            Error error = msg.GetError();
            printOutputLine("Error: " + error.Message);
        }
    }
Esempio n. 48
0
    void stateDefault()
    {
        bool inAttackRadius = (_lastPlayerPos - transform.position).magnitude < _attackRadius;

        _timer += Time.deltaTime;

        if (isPlayerVisible())
        {
            Debug.Log("player isVisible");

            _lastPlayerPos = _player.position;
            _agent.SetDestination(_lastPlayerPos);

            if (inAttackRadius)
            {
                if (_timer > _minTimeBetweenAttacks)
                {
                    _state = states.ChargingAttack;
                    _timer = 0.0f;
                }
            }
            if (!m_VroomNoise.isPlaying)
            {
                AudioClip clip = Resources.Load("Sounds/Roomba_Move") as AudioClip;
                m_VroomNoise.clip = clip;

                m_VroomNoise.Play();
            }
        }
        else
        {
            Debug.Log("player is not Visible");
            if (inAttackRadius)
            {
                _state = states.Idle;
            }
        }
    }
Esempio n. 49
0
    /* setState sets up the original and goal rotations and positions for the given state
     * state: The state the robot should go through
     * goal:  The position the robot should go to in the different states.
     * If a state does not require a position (e.g. claw movement), put any Vector3 in there
     */
    public void setState(states state, Vector3 goal)
    {
        this.state     = state;
        originRotation = this.transform.forward;
        switch (state)
        {
        case states.LEFTTURN:
            goalRotation = this.transform.right * -1;
            break;

        case states.RIGHTTURN:
            goalRotation = this.transform.right;
            break;

        case states.MOVE:
            goalPosition = goal;
            if (enableLoggingMessages)
            {
                Debug.Log("In MOVE, goal: " + goalPosition.ToString("F1"));
            }
            break;

        case states.MOVEAVOID:
            //Moveavoid is special, it os not a state to be called from the states list, but is set internally when the robot meets an obstacle to avoid
            if (enableLoggingMessages)
            {
                Debug.Log("Setting moveavoid state, goalPosition is " + goalPosition);
            }
            goalPositionTmp = goalPosition;
            goalPosition    = goal;
            if (enableLoggingMessages)
            {
                Debug.Log("My Position: " + this.transform.position + " new position: " + goalPosition);
            }
            break;
        }
        goalPosition = goal;
    }
Esempio n. 50
0
    void statePatrol()
    {
        // Patrol between waypoints
        Vector3 targetPosition = new Vector3(GameManager.instance.waypoints[controller.currentWaypoint].position.x, transform.position.y, GameManager.instance.waypoints[controller.currentWaypoint].position.z);
        Vector3 dirToWaypoint  = targetPosition - transform.position;

        if (controller.canMove())
        {
            controller.obstacleAvoidanceMove();
            controller.motor.rotateTowards(dirToWaypoint);
        }
        controller.obstacleAvoidanceMove();

        if (Vector3.Distance(transform.position, targetPosition) <= controller.toClose)
        {
            controller.getNextWaypoint();
        }
        if (controller.canSeeTarget() || controller.canHearTarget())
        {
            // go into chase state
            thisState = states.Chase;
        }
    }
Esempio n. 51
0
    private T FindClosest <T>(float maxDistance = Mathf.Infinity) where T : Component
    {
        state = states.searching;
        float      i = 0f;
        RaycastHit info;
        T          closest          = null;
        float      shortestdistance = maxDistance;

        while (i < 2.0f)
        {
            if (Physics.Raycast(transform.position, new Vector3(Mathf.Cos(i * Mathf.PI), 0f, Mathf.Sin(i * Mathf.PI)),
                                out info, maxDistance) &&
                info.collider.GetComponent <T>() != null &&
                info.distance < shortestdistance)
            {
                Debug.Log(shortestdistance + " > " + info.distance);
                closest          = info.collider.GetComponent <T>();
                shortestdistance = info.distance;
            }
            i += 0.2f;
        }
        return(closest);
    }
Esempio n. 52
0
 IEnumerator attacking()
 {
     while (myState == states.ATK)
     {
         if (control.ultimateManager.isFull())
         {
             control.setUlti();
             myState = states.RUSH;
             while (control.ultimateManager.isUltimating)
             {
                 control.mainBody.LookAt(enemyAI.target.transform.position);
                 yield return(new WaitForSeconds(2f));
             }
             myState = states.ATK;
         }
         else
         {
             control.AttackRelease();
             control.AtkBtndown();
         }
         yield return(new WaitForSeconds(0.5f));
     }
 }
Esempio n. 53
0
    IEnumerator FinishTurn()
    {
        // delay
        state = states.transitioning;
        yield return(new WaitForSeconds(0.5f));

        player += 1;
        if (player > playerLimit)
        {
            player = 1;
        }

        // update selector sprite and action sprite
        selector.FindChild("Selector1").GetComponent <SpriteRenderer>().sprite = selectorSprites[player];
        UpdateActionSprite();
        if (!CheckEnd())
        {
            // rethink the map
            UpdateBoardValues();
            DrawDebugHeatmap();
            state = states.playing;
        }
    }
Esempio n. 54
0
    void Start()
    {
        DOTween.Clear();

        if (Data.Instance.isReplay)
        {
            Invoke("Delayed", 0.5f);
            state = states.PLAYING;
        }
        else
        {
            //
        }
        Invoke("Timeout", 0.5f);
        level.Init();
        Data.Instance.events.OnGamePaused += OnGamePaused;

        Init();

        Data.Instance.events.OnListenerDispatcher += OnListenerDispatcher;
        Data.Instance.events.SetSettingsButtonStatus(false);
        Data.Instance.events.StartMultiplayerRace += StartMultiplayerRace;
    }
Esempio n. 55
0
    void ChangeState()
    {
        switch (currentState)
        {
        case states.idle:
            currentState    = states.attack;
            mySprite.sprite = sprites[1];
            break;

        case states.attack:
            currentState    = states.jump;
            mySprite.sprite = sprites[2];
            break;

        case states.jump:
            currentState    = states.idle;
            mySprite.sprite = sprites[0];
            break;

        default:
            break;
        }
    }
Esempio n. 56
0
    void statePatrol()
    {
        // patrol around randomly between waypoints
        Vector3 targetPosition = new Vector3(controller.waypoints[controller.currentWaypoint].position.x, transform.position.y, controller.waypoints[controller.currentWaypoint].position.z);
        Vector3 dirToWaypoint  = targetPosition - transform.position;

        if (controller.canMove())
        {
            controller.obstacleAvoidanceMove();
            controller.motor.rotateTowards(dirToWaypoint);
        }
        controller.obstacleAvoidanceMove();

        if (Vector3.Distance(transform.position, targetPosition) <= controller.HowClose)
        {
            controller.getNextWaypoint();
        }
        if (controller.canSeeTarget() || controller.hearTarget())
        {
            // go into chase state
            currentState = states.chase;
        }
    }
Esempio n. 57
0
    public void Run()
    {
        if (state == states.DEAD)
        {
            return;
        }
        if (state == states.IDLE)
        {
            return;
        }
        if (state == states.RUN)
        {
            return;
        }

        jumpsNumber = 0;
        state       = states.RUN;

        //if (isOver != null)
        //    RunOverOther();
        //else
        SetRunState();
    }
Esempio n. 58
0
    void OnZoom(float value)
    {
        if (state == states.DONE)
        {
            if (value == 1)
            {
                zoom = zoomIn;
            }
            else if (value == 2)
            {
                zoom = defaultZoom;
            }
            else if (value == 3)
            {
                zoom = zoomOut;
            }

            state       = states.ZOOM;
            invDuration = 1f / 0.5f;
            timerStart  = Time.time;
            Invoke("Done", 0.5f);
        }
    }
Esempio n. 59
0
    void Tower()
    {
        text.text = "You are locked in a tall tower and you are trying to escape. There are some nice clean sheets on the bed, " +
                    "an axe on the floor, and a window to look outside.\n\n" +
                    "Press W to walk around, S to pick up the clean sheets, A to pick the axe up, or L to look outside the window.";

        if (Input.GetKeyDown(KeyCode.W))
        {
            myState = states.walk;
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
            myState = states.sheets;
        }
        else if (Input.GetKeyDown(KeyCode.A))
        {
            myState = states.axe;
        }
        else if (Input.GetKeyDown(KeyCode.L))
        {
            myState = states.window;
        }
    }
Esempio n. 60
0
    void StopCarrying()
    {
        if (state == states.STOPPED_CARRYING)
        {
            return;
        }

        CancelInvoke();

        state = states.STOPPED_CARRYING;

        if (carringElement != null)
        {
            carringElement.StopBeingCarried();
            SetPivot(Vector3.zero);
            Invoke("DelayToInactive", 0.6f);
            carringElement = null;
        }
        else
        {
            Invoke("DelayToInactive", 0.05f);
        }
    }