void VerifiquePosicionamento()
    {
        int[] angulos = new int[9] {
            0, 30, -30, 45, -45, 60, -60, 90, -90
        };
        int     cont           = 0;
        bool    foi            = false;
        Vector3 charPosition   = GameController.g.Manager.transform.position;
        Vector3 baseDir        = charPosition - transform.position;
        Vector3 posDeInteresse = Vector3.zero;

        while (cont < 9 && !foi)
        {
            Vector3      dir = Quaternion.AngleAxis(angulos[cont], Vector3.forward) * baseDir;
            RaycastHit2D hit = Physics2D.Raycast(transform.position, dir, 100, 511);

            if (hit)
            {
                /*
                 * Debug.Log(cont+" raycast true "+hit.transform.name);
                 * Instantiate(mark1, hit.point, Quaternion.identity);
                 */
                Vector3 thisPoint = hit.point;
                hit = Physics2D.Linecast(hit.point + 0.25f * hit.normal, charPosition, 511);

                if (!hit)
                {
                    // Instantiate(transform.GetChild(0), thisPoint, Quaternion.identity);
                    moveDir = (thisPoint - transform.position).normalized;

                    foi = true;
                }
                else
                {
                    moveDir = dir;

                    /*
                     * Debug.Log(cont + "licast true: " + hit.transform.name);
                     * Instantiate(mark2, hit.point, Quaternion.identity);*/
                }
            }
            else
            {
                hit = Physics2D.Linecast(transform.position, charPosition, 511);
                if (hit)
                {
                    //Instantiate(transform.GetChild(0), charPosition, Quaternion.identity);

                    moveDir = -dir;
                    foi     = true;
                }
                else
                {
                    foi = false;
                }
            }

            cont++;
        }

        if (foi)
        {
            estado = EstadoDaqui.posicionandoParaAtirar;
        }
        else
        {
            moveDir = (transform.position - charPosition).normalized;
            estado  = EstadoDaqui.posicionandoEvasivamente;
            Invoke("VerificaDistanciaDeAtivacao", TEMPO_EM_EVASIVA);
        }
    }
示例#2
0
    //cast a ray from the player to see if he can activate an interaction with an object
    void Raycast()
    {
        lineStart = gameObject.transform.position;
        Debug.DrawLine(lineStart, lineEnd, Color.black);

        if (Physics2D.Linecast(lineStart, lineEnd, 1 << LayerMask.NameToLayer("Interactable")))
        {
            hitObject = Physics2D.Linecast(lineStart, lineEnd, 1 << LayerMask.NameToLayer("Interactable"));
            InteractableObject myObject = hitObject.collider.gameObject.GetComponent <InteractableObject>();
            bool hitWall;

            if (Physics2D.Linecast(lineStart, lineEnd, 1 << LayerMask.NameToLayer("Wall")))
            {
                hitWall = true;
            }
            else
            {
                hitWall = false;
            }


            float myObjectY = myObject.transform.position.y;
            float nancyY    = transform.position.y;



            if (checkGadgetPresence(myObject) == -1)
            {
                gameManager.deactivateText();
            }

            else if (checkGadgetPresence(myObject) == 0)
            {
                if ((hitWall && nancyY < myObjectY) || (!hitWall))
                {
                    gameManager.ActivateInteractionText();
                    interact = true;
                }
                else
                {
                    gameManager.deactivateText();
                    interact = false;
                }
                nearADoor = false;
                nearASafe = false;
            }
            else if (checkGadgetPresence(myObject) == 1)
            {
                gameManager.ActivateSafeText();
                nearADoor = false;
                nearASafe = true;
            }
            else if (checkGadgetPresence(myObject) == 2)
            {
                gameManager.ActivateNoKeyText();
                nearADoor = true;
                nearASafe = false;
            }
            else if (checkGadgetPresence(myObject) == 3)
            {
                gameManager.ActivateExitText();
                interact  = true;
                nearADoor = false;
                nearASafe = false;
            }
        }

        else
        {
            interact  = false;
            nearADoor = false;
            nearASafe = false;
            gameManager.deactivateText();
        }

        //if the user can interact with the object AND he presses E, he interacts
        if (Input.GetKeyDown(KeyCode.Mouse0) && interact == true)
        {
            InteractableObject myObject = hitObject.collider.gameObject.GetComponent <InteractableObject>();
            if (myObject.getObjectType() != "Endgame")
            {
                gameManager.AddMoney(myObject.Interact(), myObject.getObjectType());
            }

            else
            {
                gameManager.deactivateText();
                gameManager.win = true;
            }

            if (myObject.getObjectType() == "Key")
            {
                keyList.Add(((Key)myObject).getKeyID());
            }
        }
    }
示例#3
0
    /// <summary>
    /// execute the current state of the FSM
    /// </summary>
    void executeFSM()
    {
        //get the location of the player and enemy to figure out their coordinates
        Point playerLocation = new Point(PlayerMgr.Instance.transform.position);
        Point enemyLocation  = new Point(transform.position);

        targetCoordinate = enemyLocation;

        switch (currentEnemyState)
        {
        case EnemyState.Combat:
            //pursue the player
            targetCoordinate = Pathfinding.Instance.MovePickerA(enemyLocation, playerLocation, obstacleLayer);

            //if A* didn't find a path, keep the enemy still
            if (targetCoordinate == new Point())
            {
                targetCoordinate = enemyLocation;
            }
            break;

        case EnemyState.Flee:
            //flee from the player
            targetCoordinate = Pathfinding.Instance.FleeFromPoint(enemyLocation, playerLocation, obstacleLayer);
            break;

        case EnemyState.Idle:
            //if enemy isn't at full health already, regenerate health
            if (stats.currentHealth < stats.maxHealth)
            {
                stats.currentHealth += 1;
            }
            break;

        case EnemyState.Search:
            //look around randomly
            targetCoordinate = Pathfinding.Instance.MovePickerRandom(enemyLocation);
            break;
        }

        // Check if we can move to the next tile
        Vector3      endCoordinate = new Vector3(targetCoordinate.x, targetCoordinate.y);
        RaycastHit2D checkValid    = Physics2D.Linecast(endCoordinate, endCoordinate, obstacleLayer);

        // Collider will be null if the linecast didn't hit an obstacle
        if (checkValid.collider == null || checkValid.collider.transform == this.transform.GetChild(0))
        {
            if (targetCoordinate != enemyLocation)
            {
                moving = true;
                StartCoroutine(Move(targetCoordinate - enemyLocation));
            }
            else
            {
                moving = false;
            }
        }

        else if (checkValid.collider.gameObject.tag == "Player")
        {
            Attack();
        }
        //else	Debug.Log (checkValid.collider.gameObject.tag);
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        Vector3 targetPos = Vector3.zero;

        if (joystick)
        {
            JoystickMode();
        }
        else
        {
            targetPos = MouseMode();
        }

        if (isFacingRight > 0)
        {
            weapon.transform.parent.rotation = Quaternion.FromToRotation(Vector3.right, targetDir.normalized);
        }
        else
        {
            weapon.transform.parent.localRotation = Quaternion.FromToRotation(targetDir, Vector3.left);
        }

        Vector2 bulletPos = weapon.transform.Find("bulletSpawn").position;

        if (joystick)
        {
            Debug.DrawLine(bulletPos, bulletPos + targetDir.normalized * 100, Color.red);
        }

        //点击鼠标左键开火
        if (Input.GetButtonDown(fire1))
        {
            if (!joystick)
            {
                targetDir = (Vector2)targetPos - bulletPos;
                if (Vector3.Magnitude(targetPos - transform.position) > 10.5f)
                {
                    weapon.Fire(targetDir);
                }
            }
            else
            {
                weapon.Fire(targetDir);
            }
        }

        //点击鼠标右键投掷炸弹
        //按住蓄力
        if (Input.GetButton(fire2))
        {
            throwBomb.Charge();
        }
        //松开释放
        if (Input.GetButtonUp(fire2))
        {
            throwBomb.Throw(targetDir);
        }

        //射线检测是否碰到地面,若是则可以跳跃
        isGrounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));
        if (Input.GetButtonDown(jump) && isGrounded)
        {
            anim.SetTrigger("Jump");
            rb.AddForce(new Vector2(0, jumpForce));
            isjumping = true;
        }
        //跳跃蓄力
        if (isjumping)
        {
            rb.AddForce(new Vector2(0, jumpForce));
            jumpTimer += Time.deltaTime;
            if (jumpTimer > 0.15f)
            {
                isjumping = false;
            }
        }
        if (Input.GetButtonUp(jump))
        {
            isjumping = false;
            jumpTimer = 0;
        }

        //引爆定时炸弹
        if (Input.GetButtonUp(detonate))
        {
            if (detonateFunc != null)
            {
                detonateFunc();
            }
        }

        //和控制台交互
        if (Input.GetButtonUp(interact))
        {
            Console.Instance.ConsoleInteract();
        }
    }
示例#5
0
// Update is called once per frame
    void Update()
    {
        if (!isHanging && Input.GetMouseButtonDown(1))
        {
            Vector2 aim = new Vector2();
            aim    = Input.mousePosition;
            aim.x -= Camera.main.pixelWidth / 2f + hero.transform.position.x;
            aim.y -= Camera.main.pixelHeight / 2f + hero.transform.position.y;
            if (aim.y <= 0)
            {
                return;
            }
            hit = Physics2D.Linecast(hero.transform.position, aim, 1 << LayerMask.NameToLayer("Ground"));
            if (hit.distance <= maxCatch)
            {
                if (myJoint == null)
                {
                    myJoint = hero.AddComponent <SpringJoint2D>();
                }
                CreateSpring(hit);
            }
        }
        else if (isHanging && Input.GetMouseButtonDown(1))
        {
            if (myJoint == null)
            {
                isHanging = false;
            }
            else
            {
                springBreak();
            }
        }
        else if (isHanging && Input.GetKeyDown("w"))
        {
            springUp();
        }
        else if (isHanging && Input.GetKeyDown("s"))
        {
            springDown();
        }
        else if (isHanging && Input.GetKey("q"))
        {
            StartCoroutine(springTakeUp());
        }
        if (Input.GetKeyDown("a"))
        {
            ADown = true;
        }
        if (Input.GetKeyDown("d"))
        {
            DDown = true;
        }
        if (Input.GetKeyUp("a"))
        {
            ADown = false;
        }
        if (Input.GetKeyUp("d"))
        {
            DDown = false;
        }

        if (isHanging)
        {
            line.SetPosition(0, hero.transform.position);
            line.SetPosition(1, hit.point);

            hero.GetComponent <Rigidbody2D>().AddForce(new Vector2(0, -10f * (float)Math.Abs(Math.Cos((hit.point.y - hero.transform.position.y) / hit.distance))));
        }
    }
    // this is where most of the player controller magic happens each game event loop
    void Update()
    {
        // exit update if player cannot move or game is paused
        if (!playerCanMove || (Time.timeScale == 0f))
        {
            return;
        }

        // determine horizontal velocity change based on the horizontal input
        _vx = Input.GetAxisRaw("Horizontal");

        // Determine if running based on the horizontal movement
        if (_vx != 0)
        {
            _isRunning = true;
        }
        else
        {
            _isRunning = false;
        }

        // set the running animation state
        _animator.SetBool("Running", _isRunning);

        // get the current vertical velocity from the rigidbody component
        _vy = _rigidbody.velocity.y;

        // Check to see if character is grounded by raycasting from the middle of the player
        // down to the groundCheck position and see if collected with gameobjects on the
        // whatIsGround layer
        _isGrounded = Physics2D.Linecast(_transform.position, groundCheck.position, whatIsGround);

        // Set the grounded animation states
        _animator.SetBool("Grounded", _isGrounded);

        // Allow double jump after grounded
        if (_isGrounded && _vy <= 0f)
        {
            _canDoubleJump = true;
            _canDash       = true;
        }

        if (_isGrounded && Input.GetButtonDown("Jump"))         // If grounded AND jump button pressed, then allow the player to jump
        {
            DoJump();
        }
        else if (_canDoubleJump && Input.GetButtonDown("Jump"))
        {
            DoJump();
            _canDoubleJump = false;
        }

        // If the player stops jumping mid jump and player is not yet falling
        // then set the vertical velocity to 0 (he will start to fall from gravity)
        if (Input.GetButtonUp("Jump") && _vy > 0f)
        {
            _vy = 0f;
        }

        // Handle dropping
        bool isDownKeyPressed = Input.GetAxisRaw("Vertical") < 0f;

        if (isDownKeyPressed)
        {
            if (Physics2D.Linecast(_transform.position, groundCheck.position, LayerMask.GetMask(LayerMask.LayerToName(_platformLayer))))
            {
                DropFromPlatform();
            }
        }

        // Handle Dashing
        if (_canDash && !_isDashing)
        {
            bool isDashKeyPressed = Input.GetButtonDown("Dash");
            if (isDashKeyPressed)
            {
                Dash();
            }
        }

        if (!_isDashing)
        {
            // Change the actual velocity on the rigidbody
            _rigidbody.velocity = new Vector2(_vx * moveSpeed, _vy);
        }
        else
        {
            _rigidbody.velocity = new Vector2(_rigidbody.velocity.x, 0f);
        }

        // if moving up then don't collide with platform layer
        // this allows the player to jump up through things on the platform layer
        // NOTE: requires the platforms to be on a layer named "Platform"
        if (!_isDropping)
        {
            Physics2D.IgnoreLayerCollision(_playerLayer, _platformLayer, (_vy > 0.0f));
        }
    }
示例#7
0
    /*************************
     *  Detect Player/Alert Stuff
     **************************/
    private void CheckIfPlayerIsDetected()
    {
        if (globalalert.GetGlobalAlert() == true)
        {
            AlertMode();
        }

        bool playerseen   = ScanForPlayer();
        bool viewconeseen = thisviewcone.isDetected();

        /*************************
         * Detect Player
         **************************/

        if (playerseen && viewconeseen) //If vision cone and ray hit player
        {
            lostvisiontime         = resettime;
            playercurrentlyvisible = true;
            AlertMode();
            globalalert.GlobalAlertOn();
            if (calledin)
            {
                globalalert.GotVisual();
                calledin = false;
            }
        }
        else //Player currently not visible
        {
            playercurrentlyvisible = false;
        }


        RaycastHit2D newray = Physics2D.Linecast(this.transform.position, player.position);

        if (playerseen && newray.distance <= 1.3) //if player isn't obstructed then player is visible
        {
            playercurrentlyvisible = true;
        }


        /*************************
         * Shooting Stance
         **************************/

        if (playercurrentlyvisible && alert && !shootingstance)
        {
            shootingtimesetup -= Time.deltaTime;
            if (shootingtimesetup < 0)
            {
                shootingstance = true;
                target         = this.transform;
            }
        }

        if (shootingstance)
        {
            //Debug.Log("ShootingStance");
            shootingtime -= Time.deltaTime;
            if (shootingtime < 0)
            {
                //Debug.Log("Bang!");
                StartCoroutine(BurstFire()); //used to be shooting
                shootingstance = false;
                target         = player;
                shootingtime   = shootingresettime;
                if (!playercurrentlyvisible)
                {
                    shootingtimesetup = shootingresettime;
                }
            }
        }


        /*************************
         * Unsee Player
         **************************/

        if (alert && !playercurrentlyvisible)   //if there's an alert and player is not visible
        {
            lostvisiontime -= Time.deltaTime;

            //Lost vision timer for debugging
            // Debug.Log(lostvisiontime);
            if (lostvisiontime < 0) //if there's an alert and player is not visible for a total of lostvisiontime
            {
                if (!calledin)      //Tell GameMaster that player hasn't been visible for lostvisiontime
                {
                    globalalert.LostVisual();
                    calledin = true;
                }

                if (!globalalert.GetGlobalAlert()) //Check if Gamemaster has ceased the global alert meaning all enemies have lost contact for minimum of lostvisiontime
                {
                    NormalMode();
                }

                //add behavious of ai when lost sight of player
                //currently ai goes back to normal patrol route
            }
        }
    }
示例#8
0
    void Update()
    {
        isCealing = Physics2D.OverlapCircle(cealingCheck.position, cealingCheckRadius, ground);
        //Detector de si hay una pared delante de eva
        Vector2 groundPos = transform.position + transform.right * width;
        Vector2 vec2      = transform.right * -.02f;

        touchingWall = Physics2D.Linecast(groundPos, groundPos + vec2, ground);
        Debug.DrawLine(groundPos, groundPos + vec2);

        if (GameManagerScript.Instance.InputEnabled)
        {
            move = Input.GetAxisRaw("Horizontal");
        }
        else
        {
            move = 0;
        }

        if (move == 0 || !isGrounded || animator.GetBool("Jump") == true)
        {
            AudioManager.Stop("Steps");
        }

        //Switcheo entre animacion de idle y run
        if (move != 0)
        {
            animator.SetFloat("Speed", 1f);
            circleCollider.sharedMaterial = normalMaterial;
        }

        if (move == 0)
        {
            animator.SetFloat("Speed", 0f);
            circleCollider.sharedMaterial = superStickyMaterial;
        }


        //Input salto
        //El isGrounded es para que cuando esta colgando de la pared, si pulsas 2 veces jump, cuando toque el suelo no vuelva a saltar
        if (Input.GetButtonDown("Jump") && isGrounded && !alreadyJumped)
        {
            AudioManager.Play("Salto");
            airControl    = true;
            jump          = true;
            alreadyJumped = true;
        }
        //Double salto
        if (Input.GetButtonDown("Jump") && !isGrounded && !alreadyDoubleJumped && !animator.GetBool("Colgando"))
        {
            animator.SetBool("DobleSalto", true);
            doubleJump          = true;
            alreadyDoubleJumped = true;
            airControl          = true;
            jetpack.SetActive(true);
            AudioManager.Play("CoheteEncendiendose");
            AudioManager.Play("CoheteEncendido");
        }

        //Salto Colgando
        if (Input.GetButtonDown("Jump") && animator.GetBool("Colgando"))
        {
            AudioManager.Play("Salto");
            jumpAfterHanging          = true;
            alreadyJumpedAfterHanging = true;
            airControl = false;
        }

        //Cuando eva esta colgando en la pared despues del gancho
        if (touchingWall && !isGrounded && !hanging && rb.velocity.y < 0)
        {
            animator.SetBool("Colgando", true);
            rb.gravityScale = 5;
            animator.SetBool("Gancho", false);
            AudioManager.Stop("CoheteEncendido");
            AudioManager.Stop("CoheteEncendiendose");
            AudioManager.Play("DeslizandoseComienzo");
            AudioManager.Play("CaidaSalto");
            Invoke("DeslizandoseContinuo", 0.1f);
            animator.SetBool("Jump", false);
            hanging         = true;
            slipperIncrease = true;
            jetpack.SetActive(false);
            alreadyDoubleJumped = false;
        } //Cuando deja de tocar la pared pero sigue en el aire
        else if (!touchingWall && !isGrounded && hanging)
        {
            animator.SetBool("Colgando", false);
            hanging         = false;
            rb.gravityScale = 7;
            slipperIncrease = false;
            AudioManager.Stop("DeslizandoseContinuo");
        }
        else if (touchingWall && isGrounded && hanging)
        {
            AudioManager.Stop("DeslizandoseContinuo");
            hanging = false;
        }

        //Cuando salta hacia arriba pegada a un muro no hace la animacion de deslice hacia arriba
        if (rb.velocity.y > 0)
        {
            animator.SetBool("Colgando", false);
        }
        //Cuando no esta haciendo la animacion, que no suene, para que cuando salta delante de la pared no suene sin hacer animacion
        if (!animator.GetBool("Colgando"))
        {
            AudioManager.Stop("DeslizandoseComienzo");
            AudioManager.Stop("DeslizandoseContinuo");
        }
        //Para que cuando se quede en un borde de una rampa y salte, no de bugs con la animacion de saltar ya que no resbala del borde y el trigger esta fuera de rango
        //Pongo el animator.bool para que no afecte a deslizanose en pared
        if (!isGrounded && !animator.GetBool("Colgando"))
        {
            circleCollider.sharedMaterial = normalMaterial;
        }

        //Cuando esta haciendo la animaciendo de deslizandose por la pared, cambia el material
        if (animator.GetBool("Colgando"))
        {
            circleCollider.sharedMaterial = stickyMaterial;
        }

        if (animator.GetBool("VolandoGancho"))
        {
            AudioManager.Stop("CoheteEncendido");
            AudioManager.Stop("CoheteEncendiendose");
            jetpack.SetActive(false);
        }

        if (!isGrounded)
        {
            animator.SetBool("Landed", false);
        }
    }
示例#9
0
    private bool CanGo(Vector2 dir)
    {
        RaycastHit2D a = Physics2D.Linecast(this.transform.position, (Vector2)this.transform.position + dir, 1 << LayerMask.NameToLayer("map"));

        return(a);
    }
示例#10
0
    // Update is called once per frame
    void FixedUpdate()
    {
        // Local Variable
        float   forceX = 0f;
        float   forceY = 0f;
        Vector3 marioCurrentPosition = new Vector3(this._transform.position.x + this.cameraPositionX, this._transform.position.y + this.cameraPositionY, -10);

        this.playerCamera.position = marioCurrentPosition;

        this._isGrounded = Physics2D.Linecast(
            this._transform.position,
            this.groundCheck.position,
            1 << LayerMask.NameToLayer("Ground"));
        Debug.DrawLine(this._transform.position, this.groundCheck.position);

        float absValueX = Mathf.Abs(this._rigidbody2D.velocity.x);
        float absValueY = Mathf.Abs(this._rigidbody2D.velocity.y);


        // Check if player is grounded
        if (this._isGrounded)
        {
            this._horizontalMove = Input.GetAxis("Horizontal");
            this._verticalMove   = Input.GetAxis("Vertical");

            if (this._horizontalMove != 0)
            {
                // Check if the Right arrow is pressed
                if (this._horizontalMove > 0)
                {
                    // movement force
                    if (absValueX < this.velocityRange.maximum)
                    {
                        forceX = this.marioMoveForce;
                    }
                    this._moveLeft = true;
                    FlipMario();
                }
                // Check if the Left arrow is pressed
                if (this._horizontalMove < 0)
                {
                    // movement force
                    if (absValueX < this.velocityRange.maximum)
                    {
                        forceX = -this.marioMoveForce;
                    }
                    this._moveLeft = false;
                    FlipMario();
                }

                // Set Animation clip to walk
                this._marioAnimator.SetInteger("AnimState", 1);
            }
            else
            {
                // Set Animation clip to idle
                this._marioAnimator.SetInteger("AnimState", 0);
            }

            if (this._verticalMove > 0)
            {
                // jump force
                if (absValueY < this.velocityRange.maximum)
                {
                    this._jumpSound.Play();
                    forceY = this.marioJumpForce;
                }
            }
        }
        else
        {
            // Set Animation clip to Jump
            this._marioAnimator.SetInteger("AnimState", 2);
        }

        this._rigidbody2D.AddForce(new Vector2(forceX, forceY));
    }
    private void FixedUpdate()
    {
        //Kill the enemy
        RaycastHit2D hit = Physics2D.Raycast(groundCheck.position, Vector2.down);

        if (hit)
        {
            //Debug.Log("HITSSS" + hit.collider.gameObject.name);

            if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Enemy"))
            {
                Debug.Log("die");

                rb2d.velocity = new Vector2(rb2d.velocity.x, 1);
                Destroy(hit.collider.gameObject);
            }
        }

        if ((Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Wall"))) ||
            (Physics2D.Linecast(transform.position, groundCheckLeft.position, 1 << LayerMask.NameToLayer("Wall"))) ||
            (Physics2D.Linecast(transform.position, groundCheckRight.position, 1 << LayerMask.NameToLayer("Wall"))))
        {
            isWall       = true;
            playerFreeze = true;
        }


        if ((Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"))) ||
            (Physics2D.Linecast(transform.position, groundCheckLeft.position, 1 << LayerMask.NameToLayer("Ground"))) ||
            (Physics2D.Linecast(transform.position, groundCheckRight.position, 1 << LayerMask.NameToLayer("Ground"))))
        {
            //Debug.Log("isgrounded");
            isGrounded   = true;
            playerFreeze = true;
        }
        else
        {
            //Debug.Log("isNotgrounded");
            isGrounded = false;
        }

        if (playerFreeze)
        {
            if (Input.GetKey("left"))
            {
                if (isGrounded)
                {
                    animator.Play("character_walk");
                }
                rb2d.velocity        = new Vector2(-runSpeed, rb2d.velocity.y);
                spriteRenderer.flipX = true;
            }
            else if (Input.GetKey("right"))
            {
                if (isGrounded)
                {
                    animator.Play("character_walk");
                }
                rb2d.velocity        = new Vector2(runSpeed, rb2d.velocity.y);
                spriteRenderer.flipX = false;
            }
            else
            {
                if (isGrounded)
                {
                    animator.Play("character_idle");
                    rb2d.velocity = new Vector2(0, rb2d.velocity.y);
                }
            }

            if (Input.GetKey("up") && isGrounded)
            {
                //Debug.Log("jump");

                rb2d.velocity = new Vector2(rb2d.velocity.x, jumpSpeed);
                animator.Play("character_jump");
            }
        }
        else
        {
            animator.Play("character_jump");
            rb2d.velocity = new Vector2(0, rb2d.velocity.y);
        }
    }
示例#12
0
 RaycastHit2D detectGround()
 {
     return(Physics2D.Linecast(transform.position, groundCheck.position, groundLayer));
 }
    new public void FixedUpdate()
    {
        //checks to see if player is on ground
        grounded = Physics2D.Linecast(transform.position, groundedCheck.position, 1 << LayerMask.NameToLayer("Level"));

        DirectionCheck();


        if (inCombat == true && heroInRange == false)
        {
            Chase();
        }

        if ((attacking == true) && ((Time.time - attackStart) > attackDuration))
        {
            StopAttack();
        }

        if ((Time.time - attackCooldownStart) > attackCooldown)
        {
            canAttack = true;
        }

        if (heroInRange == true && attacking == false && canAttack == true)
        {
            Attack();
        }

        if (attacking == true && (Time.time - attackStart) > attackHitTime && attackFired == false)
        {
            AttackHit();
        }

        if (heroHit == true)
        {
            GameObject.Find("WorldState").GetComponent <WorldState>().advantageState = "Enemy Advantage";
            SendParty();
        }

        if (attacking == true)
        {
            if (rb.velocity.x > 0)
            {
                rb.velocity = new Vector2(rb.velocity.x - 0.1f, rb.velocity.y);
            }

            if (rb.velocity.x < 0)
            {
                rb.velocity = new Vector2(rb.velocity.x + 0.1f, rb.velocity.y);
            }
        }

        if ((rb.velocity.x < 1 && rb.velocity.x > -1))
        {
            Idle();
        }

        if (jumping == true && grounded == true && ((Time.time - jumpStartTime) > 1))
        {
            jumping = false;
        }
    }
示例#14
0
    // Update is called once per frame
    void Update()
    {
        if (active)
        {
            isBoosting = true;
            if (currentAmmoR >= 3)
            {
                misslesArmed   = true;
                misslesLoading = false;
            }
            else if (currentAmmoR <= 0)
            {
                misslesArmed   = false;
                misslesLoading = true;
            }


            if (currentAmmoL >= 2)
            {
                carbineArmed   = true;
                carbineLoading = false;
            }
            else if (currentAmmoL <= 0)
            {
                carbineArmed   = false;
                carbineLoading = true;
            }


            if (struck == true)
            {
                struck = false;
                StartCoroutine(showHit());
            }
            //if (sideL.hittingWall && !sideR.hittingWall)
            //{
            //    Left = false;
            //    Right = true;
            //}
            //else if (sideR.hittingWall && !sideL.hittingWall)
            //{
            //    Left = true;
            //    Right = false;
            //}
            //else if (sideR.hittingWall && sideL.hittingWall)
            //{
            //    Right = false;
            //    Left = false;
            //}
            //Armor 8 AI

            //if player not in radar range or IS in range
            //walk towards player


            //if player in viewing range
            //boost towards them
            float distance = Vector3.Distance(transform.position, Player.transform.position);

            if (!dead)
            {
                if (distance < machineGunRange)
                {
                    //isBoosting = true;
                    inCannonRange = true;
                }
                else
                {
                    //isBoosting = true;
                    inCannonRange = false;
                }
                if (distance < missileRange)
                {
                    DroneReady = true;
                }
                else
                {
                    DroneReady = false;
                }

                var mask = ~((1 << 14) | (1 << 11) | (1 << 12) | (1 << 8) | (1 << 10));
                RaycastHit2D
                    hit = Physics2D.Linecast(transform.position, Player.transform.position, mask);

                if (DroneReady && Time.time > timeStampL && currentAmmoL > 0 && hit.collider != null && hit.collider.tag == "Player")
                {
                    fireLeft      = true;
                    timeStampL    = Time.time + WlC.fireRate;
                    currentAmmoL -= 1;
                    WlC.Atk(BarrelL, AM, ally);
                }
                else if (DroneReady == false || currentAmmoL <= 0)
                {
                    fireLeft = false;
                }

                if (((fireLeft && currentAmmoL < WlC.ammo) || currentAmmoL <= 0) && Time.time > ammoTimeStampL)
                {
                    ammoTimeStampL = Time.time + WlC.reloadRate;
                    currentAmmoL  += 1;
                }

                if (carbineArmed && inCannonRange == true && Time.time > timeStampR && currentAmmoR > 0 && hit.collider != null && hit.collider.tag == "Player")
                {
                    fireRight     = true;
                    timeStampR    = Time.time + WrC.fireRate;
                    currentAmmoR -= 1;
                    WrC.Atk(BarrelR, AM, ally);
                }
                else if (!carbineArmed || !inCannonRange)
                {
                    fireRight = false;
                }

                if ((fireRight == false && (currentAmmoR < WrC.ammo) || currentAmmoR <= 0) && Time.time > ammoTimeStampR)
                {
                    ammoTimeStampR = Time.time + WrC.reloadRate;
                    currentAmmoR  += 1;
                }



                if (movement != Vector2.zero)
                {
                    Quaternion newRot = Quaternion.LookRotation(Vector3.forward, movement);
                    legsChildren.transform.rotation = newRot;
                    //Debug.Log(legsChildren.transform.localRotation.eulerAngles.z);
                    if (legsChildren.transform.localRotation.eulerAngles.z > 90 && legsChildren.transform.localRotation.eulerAngles.z < 270)
                    {
                        //    newRot = Quaternion.Inverse(newRot);
                        //    //Vector3 rot = legsChildren.transform.localRotation.eulerAngles;
                        //    //rot = new Vector3(newRot.x, newRot.y, newRot.z - 180);
                        legsChildren.transform.localScale = Vector3.down + Vector3.right + Vector3.forward;
                        //    ////rot = new Vector3(rot.x, rot.y, Mathf.Clamp(rot.z, legsChildren.transform.rotation.eulerAngles.z - 90, legsChildren.transform.rotation.eulerAngles.z + 90));
                        //    //newRot = Quaternion.Euler(rot);
                        //legsChildren.transform.rotation = rot180degrees;
                    }
                    else
                    {
                        legsChildren.transform.localScale = Vector3.up + Vector3.right + Vector3.forward;
                    }
                }
                else
                {
                    legsChildren.transform.rotation = transform.rotation;
                }

                if (path == null)
                {
                    return;
                }
                if (currentWaypoint >= path.vectorPath.Count)
                {
                    reachedEndOfPath = true;
                    return;
                }
                else
                {
                    reachedEndOfPath = false;
                }

                //            Vector2 directoin =
                movement = ((Vector2)path.vectorPath[currentWaypoint] - rb.position).normalized; //Vector3.Normalize(Player.transform.position - transform.position);

                float d = Vector2.Distance(rb.position, path.vectorPath[currentWaypoint]);
                if (d < nextWaypointDistance)
                {
                    currentWaypoint++;
                }
            }
            else
            {
                rb.velocity = Vector2.zero;
                if (Boosters.isPlaying)
                {
                    Boosters.Stop();
                }
                Anim.speed = 0;
                movement   = Vector2.zero;
            }

            //if player in shooting range
            //rotate around them and charge towards them
            //shoot the f**k out of them
            //keep a certain distance away

            //if player is really close
            //activate overdrive atk

            //if bullet is near
            //sidestep
            //if missle is near
            //sidestep and charge towards player if near

            //if energy below 20%
            //dont boost unless avoiding a projectile

            //notes: armor 8 is hyper aggressive and tanky, the strategy is to strafe and chagre until in overdrive range, this armor cares very little for their own safety



            //movement.x = Input.GetAxisRaw("Horizontal");
            //movement.y = Input.GetAxisRaw("Vertical");
        }
    }
示例#15
0
    // Update is called once per frame
    void FixedUpdate()
    {
        lives.text = "Lives: " + livesValue;
        // sends a line from player to grouncheck object position,
        // if line encounters anything on layer "ground", object is considered grounded
        if ((Physics2D.Linecast(transform.position, groundCheckM.position, 1 << LayerMask.NameToLayer("Ground"))) ||
            (Physics2D.Linecast(transform.position, groundCheckL.position, 1 << LayerMask.NameToLayer("Ground"))) ||
            (Physics2D.Linecast(transform.position, groundCheckR.position, 1 << LayerMask.NameToLayer("Ground"))))
        {
            isGrounded = true;
            animator.SetBool("isJumping", false);       //added from master
        }
        else
        {
            isGrounded = false;
            animator.SetBool("isJumping", true);        //added from master
            //  animator.Play("Player_jump");
        }
        // movement right
        if (Input.GetKey("d") || Input.GetKey("right"))
        {
            rb2d.velocity        = new Vector2(moveSpeed, rb2d.velocity.y);
            spriteRenderer.flipX = false;
            //  if(isGrounded){
            //  animator.Play("Player_run");}
        }

        //movement left
        else if (Input.GetKey("a") || Input.GetKey("left"))
        {
            rb2d.velocity        = new Vector2(-moveSpeed, rb2d.velocity.y);
            spriteRenderer.flipX = true;
            //  if(isGrounded){
            //  animator.Play("Player_run");}
        }
        else
        {
            rb2d.velocity = new Vector2(0, rb2d.velocity.y);
            //  if(isGrounded){
            //  animator.Play("Player_run");}
        }

        // player jumping
        if (Input.GetKeyDown("space") && isGrounded)
        {
            rb2d.velocity = new Vector2(rb2d.velocity.x, jumpForce);
            SoundManagerScript.PlaySound("jump");
            //  animator.Play("Player_jump");
        }

        if (currentHealth > maxHealth)
        {
            currentHealth = maxHealth;
        }
        if (currentHealth <= 0)
        {
            currentHealth = 0;
            //NOT WORKING AS INTENDID DO NOT PLAY WITH HIGH VOLUME

            /*SoundManagerScript.PlaySound("death");
             * StartCoroutine(Waitfordeath());*/

            Die();
        }
        //Added from master
        attackDelay -= Time.deltaTime;
        if (Input.GetKeyDown("x"))
        {
            Attack();
        }

        //if (Input.GetKeyDown("g"))
        //{
        //    invinsible = !invinsible;
        //    Debug.Log("Invisible: " + invinsible);
        //}

        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            moveSpeed = sprintSpeed;
        }

        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            moveSpeed = moveSpeedCopy;
        }

        animator.SetFloat("Speed", Mathf.Abs(rb2d.velocity.x));
    }
示例#16
0
    //Move returns true if it is able to move and false if not.
    //Move takes parameters for x direction, y direction and a RaycastHit2D to check collision.
    protected bool Move(int xDir, int yDir, out RaycastHit2D hit)
    {
        Vector2 start = transform.position;
        Vector2 end   = start + new Vector2(xDir, yDir);

        boxCollider.enabled = false;

        //Cast a line from start point to end point checking collision on blockingLayer.
        hit = Physics2D.Linecast(start, end, blockingLayer);
        RaycastHit2D tmpHit = hit;

        //Calculate movement if the size of enemy is big
        if (boxCollider.size.x > 1 || boxCollider.size.y > 1)
        {
            Vector2   rayEnd = new Vector2(0, 0);
            Transform player = GameObject.Find("Player").transform;
            if (yDir != 0)
            {
                for (int i = -Mathf.RoundToInt(boxCollider.size.x) / 2; i < boxCollider.size.x / 2; i++)
                {
                    start.x = transform.position.x + i;
                    rayEnd  = start + new Vector2(xDir, yDir * Mathf.Ceil(boxCollider.size.y / 2));
                    tmpHit  = Physics2D.Linecast(start, rayEnd, blockingLayer);
                    if (tmpHit.transform == player)
                    {
                        hit = tmpHit;
                        break;
                    }
                    else if (tmpHit.transform != null)
                    {
                        hit = tmpHit;
                    }
                }
            }
            else if (xDir != 0)
            {
                for (int i = -Mathf.RoundToInt(boxCollider.size.y) / 2; i < boxCollider.size.y / 2; i++)
                {
                    start.y = transform.position.y + i;
                    rayEnd  = start + new Vector2(xDir * Mathf.Ceil(boxCollider.size.x / 2), yDir);
                    tmpHit  = Physics2D.Linecast(start, rayEnd, blockingLayer);
                    if (tmpHit.transform == player)
                    {
                        hit = tmpHit;
                        break;
                    }
                    else if (tmpHit.transform != null)
                    {
                        hit = tmpHit;
                    }
                }
            }
        }

        boxCollider.enabled = true;

        if (hit.transform == null)
        {
            //If nothing was hit, start SmoothMovement co-routine passing in the Vector2 end as destination
            StartCoroutine(SmoothMovement(end));
            return(true);
        }

        return(false);
    }
示例#17
0
    // Update is called once per frame
    void FixedUpdate()
    {
        MainAnimator.SetBool("ParaWalk", b_Walk);
        MainAnimator.SetBool("ParaDown", b_Down);
        MainAnimator.SetBool("ParaDead", b_Dead);
        MainAnimator.SetBool("ParaRespawn", b_Respawn);
        MainAnimator.SetBool("ParaJump", b_Jump);
        MainAnimator.SetBool("ParaJumpUp", b_JumpUp);
        MainAnimator.SetBool("ParaJumptoFall", b_JumptoFall);
        MainAnimator.SetBool("ParaFall", b_Fall);
        MainAnimator.SetBool("ParaToGround", b_ToGround);
        TransAnimator.SetBool("ParaTransition", b_Transition);
        StartTransAnimator.SetBool("ParaStartTransition", b_StartTransition);
        EndTransAnimator.SetBool("ParaEndTransition", b_EndTransition);
        b_Respawn = true;
        if (b_canMove)
        {
            #region  鍵
            if (Input.GetKey(KeyCode.UpArrow))
            {
                if (b_canJump == true)
                {
                    GetComponent <Rigidbody2D>().AddForce(Vector2.up * f_JumpHeight);
                    b_JumpUp  = true;
                    b_canJump = false;
                    Jump.Play();
                }
            }
            #endregion

            #region 右鍵
            if (Input.GetKey(KeyCode.RightArrow))
            {
                Player.eulerAngles = Vector3.zero;//將角色面向方向回歸初始值
                Player.Translate(f_Speed, 0, 0);
                b_Walk = true;
            }
            #endregion

            #region 左鍵
            if (Input.GetKey(KeyCode.LeftArrow))
            {
                Player.eulerAngles = new Vector3(0, 180, 0);//旋轉角色面向方向
                Player.Translate(f_Speed, 0, 0);
                b_Walk = true;
            }
            #endregion

            if (Input.GetKeyUp(KeyCode.RightArrow) || Input.GetKeyUp(KeyCode.LeftArrow))
            {
                b_Walk = false;
            }
        }
        #region  鍵
        if (b_canJump)
        {
            if (Input.GetKey(KeyCode.DownArrow))
            {
                b_Down    = true;
                b_canMove = false;
                PlayerBoxCollider.size   = new Vector2(3.78f, 1.77f);
                PlayerBoxCollider.offset = new Vector2(0, -0.98f);
            }
            else
            {
                b_Down = false;
                PlayerBoxCollider.size   = new Vector2(3.78f, 2.65f);
                PlayerBoxCollider.offset = new Vector2(0, -0.51f);
            }
        }
        #endregion

        // if (Input.GetKey(KeyCode.D))
        // {
        //     Respawn();
        // }

        if (b_OnGround == false && PlayerRigid.velocity.y > 1)//上升中
        {
            b_Jump       = true;
            b_JumpUp     = false;
            b_JumptoFall = false;
            b_Fall       = false;
        }
        if (b_OnGround == false && PlayerRigid.velocity.y > 0 && 1 > PlayerRigid.velocity.y)//最高點中
        {
            b_JumptoFall = true;
            b_JumpUp     = false;
            b_Jump       = false;
            b_Fall       = false;
        }
        if (b_OnGround == false && PlayerRigid.velocity.y < 0)//下降中
        {
            b_Fall       = true;
            b_JumpUp     = false;
            b_Jump       = false;
            b_JumptoFall = false;
        }

        Debug.DrawLine(raystart.position, rayend.position, Color.green);
        ray = Physics2D.Linecast(raystart.position, rayend.position, 1 << LayerMask.NameToLayer("floor"));
        Debug.DrawLine(ray2start.position, ray2end.position, Color.green);
        ray2 = Physics2D.Linecast(ray2start.position, ray2end.position, 1 << LayerMask.NameToLayer("floor"));
        if (ray == true || ray2 == true)
        {
            b_canJump  = true;
            b_OnGround = true;

            b_JumpUp     = false;
            b_Jump       = false;
            b_JumptoFall = false;
            b_Fall       = false;
            b_ToGround   = true;
        }
        else
        {
            b_OnGround = false;
            b_ToGround = false;
        }
    }
示例#18
0
    void Update()
    {
        tmpI = personaC.selectSlot;

        Vector2 aux      = new Vector3(2, 3);
        Vector2 sub      = personagem.transform.position - transform.position;
        Vector2 positivo = ((personagem.transform.position - transform.position) * (-1));



        transform.position = new Vector3(Mathf.Floor(mouse.transform.position.x), Mathf.Floor(mouse.transform.position.y), 0);

        RaycastHit2D startR = Physics2D.Linecast(start.transform.position, new Vector2(start.transform.position.x, start.transform.position.y + 0.001f));
        RaycastHit2D endR   = Physics2D.Linecast(start.transform.position, new Vector2(start.transform.position.x, start.transform.position.y + 0.001f));
        RaycastHit2D startE = Physics2D.Linecast(start.transform.position, new Vector2(start.transform.position.x, start.transform.position.y + 0.001f));
        RaycastHit2D endE   = Physics2D.Linecast(start.transform.position, new Vector2(start.transform.position.x, start.transform.position.y + 0.001f));


        if (startR == true && endR == true && startR.collider.tag.StartsWith("min") && endR.collider.tag.StartsWith("min"))
        {
            if (inv.inventairo[tmpI] != null && inv.inventairo[tmpI].type == Type.CONSTRUCOES && inv.inventairo[tmpI].nomes == "mesa")
            {
                mesa.SetActive(true);
                fornalha.SetActive(false);
            }
            else
            {
                mesa.SetActive(false);
            }
            if (inv.inventairo[tmpI] != null && inv.inventairo[tmpI].type == Type.CONSTRUCOES && inv.inventairo[tmpI].nomes == "fornalha")
            {
                mesa.SetActive(false);
                fornalha.SetActive(true);
            }

            else
            {
                fornalha.SetActive(false);
            }
            if (inv.inventairo[tmpI] != null && inv.inventairo[tmpI].type == Type.CONSTRUCOES && inv.inventairo[tmpI].nomes == "Fogueira")
            {
                mesa.SetActive(false);
                fornalha.SetActive(false);
                fogueira.SetActive(true);
            }

            else
            {
                fogueira.SetActive(false);
            }
        }
        else
        {
            mesa.SetActive(false);
            fornalha.SetActive(false);
            fogueira.SetActive(false);
        }

        if (Input.GetButtonDown("Fire1") && sub.x <= aux.x && sub.y <= aux.y && positivo.x <= aux.x && positivo.y <= aux.y)
        {
            if (startR == true && endR == true && startR.collider.tag.StartsWith("min") && endR.collider.tag.StartsWith("min"))
            {
                if (inv.inventairo[tmpI] != null && inv.inventairo[tmpI].type == Type.CONSTRUCOES && inv.inventairo[tmpI].nomes == "mesa")
                {
                    inv.inventairo[tmpI].amount -= 1;
                    Instantiate(cons[0], mesa.transform.position, Quaternion.identity);
                    mesa.SetActive(true);
                }
                if (inv.inventairo[tmpI] != null && inv.inventairo[tmpI].type == Type.CONSTRUCOES && inv.inventairo[tmpI].nomes == "fornalha")
                {
                    inv.inventairo[tmpI].amount -= 1;
                    Instantiate(cons[1], fornalha.transform.position, Quaternion.identity);
                    fornalha.SetActive(true);
                }
                if (inv.inventairo[tmpI] != null && inv.inventairo[tmpI].type == Type.CONSTRUCOES && inv.inventairo[tmpI].nomes == "Fogueira")
                {
                    inv.inventairo[tmpI].amount -= 1;
                    Instantiate(cons[2], fogueira.transform.position, Quaternion.identity);
                    fogueira.SetActive(true);
                }
            }
        }
    }
    private void LookAhead()
    {
        isGroundAhead = Physics2D.Linecast(transform.position, LookAheadPoint.position, CollisionLayer);

        Debug.DrawLine(transform.position, LookAheadPoint.position, Color.green);
    }
示例#20
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Attack();
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            Jump();
        }
        if (GetComponent <SpriteRenderer>().isVisible)
        {
            player_show = true;
        }
        else
        {
            player_show = false;
        }
        combo_Endless_add1 = Skeleton_f_Endless.Get_Combo_Endless1();
        combo_Endless_add2 = Skeleton_n_Endless.Get_Combo_Endless2();
        combo_Endless_add3 = Skeleton_s_Endless.Get_Combo_Endless3();
        combo_Endless_add4 = Skeleton_s_gold_Endless.Get_Combo_Endless4();
        GameStart_f        = script.GS_f;
        StageFade_f        = script4.SF_f;


        /*
         * if (life_cnt_f == true && life_cnt < 6)
         * {
         *  Debug.Log("OOOOO");
         *  life_cnt++;
         *  life_cnt_f = false;
         * }
         */

        if (GameStart_f == true || StageFade_f == true)
        {
            if (count > 0)
            {
                amountcount  = UIobj.fillAmount;
                UItex.text   = string.Format("" + count);
                super_shot_f = false;
                gauge_check  = 0;
                if (roop)
                {
                    //Reduce fill amount over 30 seconds
                    UIobj.fillAmount -= 1.0f / countTime * Time.deltaTime;
                }
                else if (!roop)
                {
                    UIobj.fillAmount += 1.0f / countTime * Time.deltaTime;
                }

                if (UIobj.fillAmount == 0 || UIobj.fillAmount == 1)
                {
                    count = count - 1;
                    UIobj.fillClockwise = !UIobj.fillClockwise;
                    roop = !roop;
                }
            }
            if (count == 0)
            {
                UItex.text = string.Format("OK");
            }
        }

        grounded = Physics2D.Linecast(transform.position, transform.position - transform.up * 5.0f, groundlayer);
        //isTouched = GetComponent<Rigidbody2D>().IsTouching(filter2d);
        timer += Time.deltaTime;
        //攻撃処理
        //Debug.Log("space_cnt" + space_cnt);
        if (space_cnt >= 8 && tired_timer <= 2.0f)  //2秒間にスペースキーを8回押されると、動けなくなる。
        {
            space_not   = true;
            tired_timer = tired_timer_num;
            space_cnt   = 0;
        }
        if (tired_timer > 2.0f && space_not == false)
        {
            space_cnt   = 0;
            tired_timer = 0;
        }
        if (space_not == true)
        {
            UI_obj.SetActive(true);
            space_check = false;
            MainSpriteRenderer.sprite = TiredbySprite;
            tired_timer -= Time.deltaTime;
            //gauge.GetComponent<Image>().fillAmount = tired_timer / tired_timer_num;
            float _currentTired        = tired_timer / tired_timer_num;
            float currentTired_percent = _currentTired * 100;
            if (60.0f <= currentTired_percent)
            {
                TiredGauge3.SetActive(true);
            }
            if (60.0f > currentTired_percent)
            {
                TiredGauge3.SetActive(false);
                TiredGauge2.SetActive(true);
            }
            if (30.0f > currentTired_percent)
            {
                TiredGauge2.SetActive(false);
                TiredGauge1.SetActive(true);
            }

            if (currentTired_percent < 0)
            {
                UI_obj.SetActive(false);
                TiredGauge1.SetActive(false);
                space_not   = false;
                space_cnt   = 0;
                tired_timer = 0;
                MainSpriteRenderer.sprite = WaitbySprite;
            }
        }
        if (space_cnt >= 1 && space_not == false)
        {
            //攻撃処理
            tired_timer += Time.deltaTime;
        }
        //コンボ文字の非表示処理
        if (combo_f == true)
        {
            combo_timer += Time.deltaTime;
            if (combo_timer >= 2.0f)
            {
                comboActive.SetActive(false);
                comboLabelActive.SetActive(false);
                combo_f     = false;
                combo_timer = 0;

                TextPlus.SetActive(false);
                ComboTextPlus.SetActive(false);
            }
        }

        //0.5秒間スペースキーを押さなかった場合
        if (timer > 0.5f && space_not == false)
        {
            space_check = false;
            MainSpriteRenderer.sprite = WaitbySprite;
        }

        if (hit_check1 == true)
        {//敵に当たった時、点滅処理
            if (Time.time > nextTime && time_cnt < 40 && time_f == true)
            {
                Renderer ren = gameObject.GetComponent <Renderer>();
                ren.enabled = !ren.enabled;
                nextTime   += interval;
                time_cnt++;
                if (time_cnt == 40)
                {
                    time_cnt   = 0;
                    time_f     = false;
                    hit_check1 = false;
                }
            }
        }

        /*
         * if (bless_ff == true){
         *  hit_check1 = true;
         *  time_f = true;
         *  if (life > 0)
         *  {
         *      life -= 1;
         *  }
         *  PlayerPrefs.SetInt("Heart", life);
         *  PlayerPrefs.Save();
         *  sound02.PlayOneShot(sound02.clip);
         *  combo_score_f = true;
         *  TextPlus.SetActive(true);
         *  ComboTextPlus.SetActive(true);
         *  script2.Combo_Score();
         *  if (life <= 0)
         *  {
         *      SceneManager.LoadScene("GameOver_Endless");
         *      //SceneManager.LoadScene("Reward");
         *  }
         * }
         */
        if (combo_Endless_add1 == true || combo_Endless_add2 == true || combo_Endless_add3 == true || combo_Endless_add4 == true)
        {
            //コンボ成立
            comboActive.SetActive(true);
            comboLabelActive.SetActive(true);
            FindObjectOfType <Combo_Endless>().AddPoint(1);
            TextAnim_ComboLabel.GetComponent <TypefaceAnimator>().Play();
            TextAnim_Combo.GetComponent <TypefaceAnimator>().Play();
            combo_f     = true;
            combo_timer = 0;
        }
    }
示例#21
0
    // this is where most of the player controller magic happens each game event loop
    void Update()
    {
        // exit update if player cannot move or game is paused
        if (!playerCanMove || (Time.timeScale == 0f))
        {
            return;
        }

        // determine horizontal velocity change based on the horizontal input
        _vx = CrossPlatformInputManager.GetAxisRaw("Horizontal");

        // Determine if running based on the horizontal movement
        if (_vx != 0)
        {
            _isRunning = true;
        }
        else
        {
            _isRunning = false;
        }

        // set the running animation state
        _animator.SetBool("Running", _isRunning);

        // get the current vertical velocity from the rigidbody component
        _vy = _rigidbody.velocity.y;

        // Check to see if character is grounded by raycasting from the middle of the player
        // down to the groundCheck position and see if collected with gameobjects on the
        // whatIsGround layer
        _isGrounded = Physics2D.Linecast(_transform.position, groundCheck.position, whatIsGround);

        //allow double jump after grounded
        if (_isGrounded)
        {
            _canDoubleJump = true;
        }


        // Set the grounded animation states
        _animator.SetBool("Grounded", _isGrounded);

        if (_isGrounded && CrossPlatformInputManager.GetButtonDown("Jump"))         // If grounded AND jump button pressed, then allow the player to jump
        {
            DoJump();
        }
        else if (_canDoubleJump && CrossPlatformInputManager.GetButtonDown("Jump"))           //is can double jump and input is jump key
        {
            DoJump();
            _canDoubleJump = false;             //must set to fase as doublle jump can only be called once
        }

        // If the player stops jumping mid jump and player is not yet falling
        // then set the vertical velocity to 0 (he will start to fall from gravity)
        if (CrossPlatformInputManager.GetButtonUp("Jump") && _vy > 0f)
        {
            _vy = 0f;
        }

        // Change the actual velocity on the rigidbody
        _rigidbody.velocity = new Vector2(_vx * moveSpeed, _vy);

        // if moving up then don't collide with platform layer
        // this allows the player to jump up through things on the platform layer
        // NOTE: requires the platforms to be on a layer named "Platform"
        Physics2D.IgnoreLayerCollision(_playerLayer, _platformLayer, (_vy > -1.0f));
    }
示例#22
0
    void Update()
    {
        // If mario small then animator and change the boxcollider small
        if (statusMario == 0)
        {
            animator.runtimeAnimatorController = Marios[0];
            bc.size   = new Vector2(0.65f, 0.8f);
            bc.offset = new Vector2(0, 0.4f);
        }
        // If supermario then animator and change the boxcollider big
        if (statusMario == 1)
        {
            animator.runtimeAnimatorController = Marios[1];
            if (!isCouch)
            {
                bc.size   = new Vector2(0.8f, 1.5f);
                bc.offset = new Vector2(0, 0.8f);
            }
        }
        // If fire mario  then animator and change the boxcollider big
        if (statusMario == 2)
        {
            animator.runtimeAnimatorController = Marios[2];
            if (!isCouch)
            {
                bc.size   = new Vector2(0.8f, 1.5f);
                bc.offset = new Vector2(0, 0.8f);
            }
        }
        // If mario was hit start Hit effect
        if (marioHit)
        {
            gm.UpdateDebug("Mario hit");
            StartCoroutine(Hit());
            marioHit = false;
        }
        // If mario death start Death effect
        if (marioDeath && statusMario != 4)
        {
            SoundSystem.ss.StopMusic();
            SoundSystem.ss.PlayDeath();
            StartCoroutine(Death());
        }
        // Set al objects for pause
        allObjects = GameObject.FindObjectsOfType <GameObject>();
        koopas     = GameObject.FindGameObjectsWithTag("koopa");
        goombas    = GameObject.FindGameObjectsWithTag("goomba");
        shells     = GameObject.FindGameObjectsWithTag("shell");

        startRaycastRight = raycast.transform.position;
        endRaycastRight   = new Vector3(raycast.transform.position.x + raycastLength, raycast.transform.position.y, 0);

        RaycastHit2D hitRight = Physics2D.Linecast(startRaycastRight, endRaycastRight);

        Debug.DrawLine(startRaycastRight, endRaycastRight, Color.red);

        if (hitRight.collider != null)
        {
            if (hitRight.collider.tag == "shell" && lookRight)
            {
                Shell = hitRight.collider.gameObject;
                if (Shell.GetComponent <Shell>().velocityKoopa == 0)
                {
                    gm.UpdateDebug("Mario can't be hit");
                    StartCoroutine(NoHit());
                    Shell.GetComponent <Shell>().velocityKoopa = 4f;
                }
            }
        }

        startRaycastLeft = raycast.transform.position;
        endRaycastLeft   = new Vector3(raycast.transform.position.x - raycastLength, raycast.transform.position.y, 0);

        RaycastHit2D hitLeft = Physics2D.Linecast(startRaycastLeft, endRaycastLeft);

        Debug.DrawLine(startRaycastLeft, endRaycastLeft, Color.red);


        if (hitLeft.collider != null)
        {
            if (hitLeft.collider.tag == "shell" && !lookRight)
            {
                Shell = hitLeft.collider.gameObject;
                if (Shell.GetComponent <Shell>().velocityKoopa == 0)
                {
                    gm.UpdateDebug("Mario can't be hit");
                    StartCoroutine(NoHit());
                    Shell.GetComponent <Shell>().velocityKoopa = -4f;
                }
            }
        }
    }
示例#23
0
 // Cast ray in choosen position and check if it is collaiding with player
 public void Raycasting()
 {
     Debug.DrawLine(body2d.position, rayEnd.position, Color.red);
     playerSpotted = Physics2D.Linecast(body2d.position, rayEnd.position, 1 << LayerMask.NameToLayer("Player"));
 }
    // Update is called once per frame
    void Update()
    {
        // The player is grounded if a linecast to the groundcheck position hits anything on the ground layer.
        grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));

        //Movement
        if (Input.GetKeyDown(KeyCode.A) && grounded && !crouch)
        {
            left = true;
        }
        if (Input.GetKeyDown(KeyCode.D) && grounded && !crouch)
        {
            right = true;
        }
        if (Input.GetKeyUp(KeyCode.A) && grounded)
        {
            left = false;
        }
        if (Input.GetKeyUp(KeyCode.D) && grounded)
        {
            right = false;
        }

        if (Input.GetKeyDown(KeyCode.S) && grounded)
        {
            crouch = true;
        }
        if (Input.GetKeyUp(KeyCode.S) && grounded)
        {
            crouch = false;
        }
        if (Input.GetKeyDown(KeyCode.W) && grounded)
        {
            jump = true;
        }
        //Punches
        if (Input.GetKeyDown(KeyCode.Y) && grounded)
        {
            lp = true;
        }
        if (Input.GetKeyDown(KeyCode.U) && grounded)
        {
            mp = true;
        }
        if (Input.GetKeyDown(KeyCode.I) && grounded)
        {
            hp = true;
        }

        if (Input.GetKeyUp(KeyCode.Y) && grounded)
        {
            lp = false;
        }
        if (Input.GetKeyUp(KeyCode.U) && grounded)
        {
            mp = false;
        }
        if (Input.GetKeyUp(KeyCode.I) && grounded)
        {
            hp = false;
        }

        //Kicks
        if (Input.GetKeyDown(KeyCode.H) && grounded)
        {
            lk = true;
        }
        if (Input.GetKeyDown(KeyCode.J) && grounded)
        {
            mk = true;
        }
        if (Input.GetKeyDown(KeyCode.K) && grounded)
        {
            hk = true;
        }

        if (Input.GetKeyUp(KeyCode.H) && grounded)
        {
            lk = false;
        }
        if (Input.GetKeyUp(KeyCode.J) && grounded)
        {
            mk = false;
        }
        if (Input.GetKeyUp(KeyCode.K) && grounded)
        {
            hk = false;
        }

        /*if(Input.GetKeyDown(KeyCode.F))
         * {Flip (); Debug.Log("Flip");}*/

        if (Input.GetKeyDown(KeyCode.T))
        {
            Debug.Log(Time.time);
        }
    }
示例#25
0
    void Update()
    {
        estadoGoblin = Goblin.GetComponent <Moviment>().estadoGoblin;
        muerteGoblin = Goblin.GetComponent <Moviment>().GoblimMuerte;

        //RAYCAST 2D

        //RAY DRETA
        InicioRayoDerecha = Rayos.transform.position;
        FinRayoDerecha    = new Vector3(Rayos.transform.position.x + ajusteRaycast, Rayos.transform.position.y, 0);

        RaycastHit2D hitDerecha = Physics2D.Linecast(InicioRayoDerecha, FinRayoDerecha);

        Debug.DrawLine(InicioRayoDerecha, FinRayoDerecha, Color.cyan);

        if (hitDerecha.collider != null)
        {
            if (hitDerecha.collider.gameObject != Goblin)
            {
                CambioDireccion();
            }

            if (hitDerecha.collider.gameObject.tag == "goblin" && rb.velocity != Vector2.zero && !muerteGoblin)
            {
                Goblin.GetComponent <Moviment>().GoblimMuerte = true;
                gm.RestarVidas();
            }
        }

        //RAY ESQUERRA
        InicioRayoIzquierda = Rayos.transform.position;
        FinRayoIzquerda     = new Vector3(Rayos.transform.position.x - ajusteRaycast, Rayos.transform.position.y, 0);

        RaycastHit2D hitIzquierda = Physics2D.Linecast(InicioRayoIzquierda, FinRayoIzquerda);

        Debug.DrawLine(InicioRayoIzquierda, FinRayoIzquerda, Color.cyan);

        if (hitIzquierda.collider != null)
        {
            if (hitIzquierda.collider.gameObject != Goblin)
            {
                CambioDireccion();
            }

            if (hitIzquierda.collider.gameObject.tag == "goblin" && rb.velocity != Vector2.zero && !muerteGoblin)
            {
                Goblin.GetComponent <Moviment>().GoblimMuerte = true;
                gm.RestarVidas();
            }
        }

        //RAY SUPERIOR
        InicioRayoSuperior = DeteccionArriba.transform.position;
        FinRayoSuperior    = new Vector3(DeteccionArriba.transform.position.x, DeteccionArriba.transform.position.y + ajusteRaycast, 0);

        RaycastHit2D hitSuperior = Physics2D.Linecast(InicioRayoSuperior, FinRayoSuperior);

        Debug.DrawLine(InicioRayoSuperior, FinRayoSuperior, Color.cyan);

        if (hitSuperior.collider != null)
        {
            if (hitSuperior.collider.gameObject == Pie && !muerteGoblin && !muerto)
            {
                StartCoroutine(Muerte());
            }
        }

        InicioRayoSuperior2 = DeteccionArriba2.transform.position;
        FinRayoSuperior2    = new Vector3(DeteccionArriba2.transform.position.x, DeteccionArriba2.transform.position.y + ajusteRaycast, 0);

        RaycastHit2D hitSuperior2 = Physics2D.Linecast(InicioRayoSuperior2, FinRayoSuperior2);

        Debug.DrawLine(InicioRayoSuperior2, FinRayoSuperior2, Color.cyan);

        if (hitSuperior2.collider != null)
        {
            if (hitSuperior2.collider.gameObject == Pie && !muerteGoblin && !muerto)
            {
                StartCoroutine(Muerte());
            }
        }

        InicioRayoSuperior3 = DeteccionArriba3.transform.position;
        FinRayoSuperior3    = new Vector3(DeteccionArriba3.transform.position.x, DeteccionArriba3.transform.position.y + ajusteRaycast, 0);

        RaycastHit2D hitSuperior3 = Physics2D.Linecast(InicioRayoSuperior3, FinRayoSuperior3);

        Debug.DrawLine(InicioRayoSuperior3, FinRayoSuperior3, Color.cyan);

        if (hitSuperior3.collider != null)
        {
            if (hitSuperior3.collider.gameObject == Pie && !muerteGoblin && !muerto)
            {
                StartCoroutine(Muerte());
            }
        }


        //DETECCIO CAIGUDA
        InicioRayoCaida = DeteccionCaida.transform.position;
        FinRayoCaida    = new Vector3(DeteccionCaida.transform.position.x, DeteccionCaida.transform.position.y - ajusteRaycast, 0);

        RaycastHit2D hitCaida = Physics2D.Linecast(InicioRayoCaida, FinRayoCaida);

        Debug.DrawLine(InicioRayoCaida, FinRayoCaida, Color.cyan);

        if (hitCaida.collider == null)
        {
            CambioDireccion();
        }
    }
示例#26
0
    void Raycast()
    {
        Debug.DrawLine(transform.position, jumpCheck.position, Color.magenta);

        grounded = Physics2D.Linecast(transform.position, jumpCheck.position, 1 << LayerMask.NameToLayer("grounded"));
    }
示例#27
0
    // Update is called once per frame
    void Update()
    {
        //Linecastでプレイヤーの足元にフレームがあるか判定
        isFramed = Physics2D.Linecast(
            transform.position + transform.up * 1,
            transform.position - transform.up * 0.05f,
            frameLayer);

        //Linecastでプレイヤーがフレームに触れていたら破壊
        if (isFramed)
        {
            Destroy(gameObject);
            GameObject.Find("GameOver").SendMessage("Lose");
        }


        //Linecastでプレイヤーの足元に地面があるか判定
        isGrounded = Physics2D.Linecast(
            transform.position + transform.up * 1,
            transform.position - transform.up * 0.05f,
            groundLayer);

        //上下への移動速度を取得
        float velY = rigid2D.velocity.y;
        //移動速度が0.1より大きければ上昇
        bool isJumping = velY > 0.1f ? true:false;
        //移動速度が-0.1より小さければ下降
        bool isFalling = velY < -0.1f ? true:false;

        //結果をアニメータービューの変数へ反映する
        animator.SetBool("isJumping Bool", isJumping);
        animator.SetBool("isFalling Bool", isFalling);


        //画面中央から左に4移動した位置をユニティちゃんが超えたら
        if (transform.position.x > mainCamera.transform.position.x - 4)
        {
            //カメラの位置を取得
            Vector3 cameraPos = mainCamera.transform.position;
            //プレイヤーの位置から右に4移動した位置を画面中央にする
            cameraPos.x = transform.position.x + 4;
            mainCamera.transform.position = cameraPos;
        }

        if (transform.position.y < 0)
        {
            //カメラの位置を取得
            Vector3 cameraPos = mainCamera.transform.position;
            //プレイヤーの位置から右に4移動した位置を画面中央にする
            cameraPos.y = 0;
            mainCamera.transform.position = cameraPos;
        }
        else
        {
            Vector3 cameraPos = mainCamera.transform.position;
            //プレイヤーの位置から右に4移動した位置を画面中央にする
            cameraPos.y = transform.position.y;
            mainCamera.transform.position = cameraPos;
        }



        //カメラ表示領域の左下をワールド座標に変換
        Vector2 min = Camera.main.ViewportToWorldPoint(new Vector2(0, 0));
        //カメラ表示領域の右上をワールド座標に変換
        Vector2 max = Camera.main.ViewportToWorldPoint(new Vector2(1, 1));
        //プレイヤーのポジションを取得
        Vector2 pos = transform.position;

        //プレイヤーのx座標の移動範囲をClampメソッドで制限
        pos.x = Mathf.Clamp(pos.x, min.x + 0.5f, max.x);
        transform.position = pos;
    }
    private void FixedUpdate()
    {
        if ((Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"))) ||
            (Physics2D.Linecast(transform.position, groundCheckL.position, 1 << LayerMask.NameToLayer("Ground"))) ||
            (Physics2D.Linecast(transform.position, groundCheckR.position, 1 << LayerMask.NameToLayer("Ground"))))
        {
            isGrounded = true;
        }



        else
        {
            isGrounded = false;
            if (!isAttacking)
            {
                Newanimator.Play("GokuMan_Jump");
            }
        }

        if (Input.GetKey("d") && !isMoving)
        {
            Newrb2d.velocity = new Vector2(runSpeed, Newrb2d.velocity.y);
            if (isGrounded && !isAttacking)
            {
                Newanimator.Play("GokuMan_Run");
            }


            //NewspriteRenderer.flipX = false;
            transform.localScale = new Vector3(1, 1, 1);
            isFacingLeft         = false;
        }
        else if (Input.GetKey("a") && !isMoving)
        {
            Newrb2d.velocity = new Vector2(-runSpeed, Newrb2d.velocity.y);
            if (isGrounded && !isAttacking)
            {
                Newanimator.Play("GokuMan_Run");
            }


            //NewspriteRenderer.flipX = true;
            transform.localScale = new Vector3(-1, 1, 1);

            isFacingLeft = true;
        }
        else if (isGrounded)
        {
            if (!isAttacking)
            {
                //Newanimator.Play("AverageJoe_Idle");
            }

            Newrb2d.velocity = new Vector2(0, Newrb2d.velocity.y);
        }

        if (Input.GetKey("space") && isGrounded == true)
        {
            Newrb2d.velocity = new Vector2(Newrb2d.velocity.x, jumpSpeed);
            Newanimator.Play("GokuMan_Jump");
        }
    }
示例#29
0
    // Update is called once per frame
    void Update()
    {
        vec_target   = Target.transform.position - transform.position;
        vec_target3D = new Vector3(vec_target.x, vec_target.y, 0.0f);

        //Determine si doit suivre
        if (Follow_target)
        {
            if (vec_target.y < size_circle + target_circle && vec_target.magnitude < start_chase)
            {
                Follow_mode = true;
            }
            else
            {
                Follow_mode = false;
            }
        }

        //Determine si ligne de vue
        if (ligne_vue)
        {
            hit    = Physics2D.LinecastAll(transform.position + vec_target3D.normalized * 2 * size_circle, Target.transform.position - vec_target3D.normalized * target_circle * 2);
            nb_hit = Physics2D.LinecastNonAlloc(transform.position + vec_target3D.normalized * 2 * size_circle, Target.transform.position - vec_target3D.normalized * target_circle * 2, hit);
            Debug.DrawLine(transform.position + vec_target3D.normalized * 2 * size_circle, Target.transform.position - vec_target3D.normalized * target_circle * 2, Color.yellow);
            has_sight = true;
            for (int i = 0; i < nb_hit; i++)
            {
                if (!(hit[i].collider.tag == "missile"))
                {
                    has_sight = false;
                }
            }

            if (has_sight && vec_target.x * is_rightorleft() > 0)
            {
                OnSight_mode = true;
            }
            else
            {
                OnSight_mode = false;
            }
        }
        else
        {
            OnSight_mode = true;
        }

        //Parametrage Follow trajet
        if (Follow_trajet)
        {
            //if (vec_ward.magnitude < ward_dstop && !Onchase_mode)
            Debug.DrawLine(transform.position, go_ward.transform.position, Color.green);
            vec_ward = go_ward.transform.position - transform.position;
            if (Mathf.Abs(vec_ward.x) < ward_stop)
            {
                go_ward = go_ward.GetComponent <Trajet_Beacon>().Next_beacon;
                //Debug.Log("Change ward");
                if (!Onchase_mode)
                {
                    bounce();
                }
            }
        }

        //Risque de chute et mur
        if (stay_onplateform)
        {
            hit_s = Physics2D.Linecast(transform.position + new Vector3(is_rightorleft() * 3 * size_circle, 0.0f, 0.0f), transform.position + new Vector3(is_rightorleft() * 3 * size_circle, -3 * size_circle, 0.0f));
            hit_m = Physics2D.Linecast(transform.position + new Vector3(is_rightorleft() * 2 * size_circle, 0.0f, 0.0f), transform.position + new Vector3(is_rightorleft() * 4 * size_circle, 0.0f, 0.0f));
            Debug.DrawLine(transform.position + new Vector3(is_rightorleft() * 3 * size_circle, 0.0f, 0.0f), transform.position + new Vector3(is_rightorleft() * 3 * size_circle, -3 * size_circle, 0.0f), Color.red);
            Debug.DrawLine(transform.position + new Vector3(is_rightorleft() * 2 * size_circle, 0.0f, 0.0f), transform.position + new Vector3(is_rightorleft() * 4 * size_circle, 0.0f, 0.0f), Color.blue);

            //Debug.Log(Time.time + time_check);
            if (Time.time - time_check > 0.01f)//(1/speed)*size_circle)
            {
                /*
                 * //Le debug
                 * if (hit_m.collider != null)
                 * {
                 *  Debug.Log(hit_m.collider.name);
                 * }
                 * if (hit_s.collider == null)
                 * {
                 *  Debug.Log("Ne touche pas le sol");
                 * }
                 */

                if (hit_m.collider != null)
                {
                    if (hit_m.collider.tag == "Player")
                    {
                        Animator_Ennemi.SetBool("attack", true);
                    }
                    else if (hit_m.collider.tag != "missile")
                    {
                        bounce();
                        time_check = Time.time;
                    }
                }

                else if (hit_s.collider == null || hit_m.collider != null)
                {
                    bounce();
                    time_check = Time.time;
                }
            }
            else
            {
                Fall_mode = false;
            }
        }
        else
        {
            Fall_mode = false;
        }
    }
    // Update is called once per frame
    void Update()
    {
        Vector3 charPos = default;

        if (GameController.g)
        {
            if (GameController.g.Manager)
            {
                charPos = GameController.g.Manager.transform.position;
            }
        }

        switch (estado)
        {
        case EstadoDaqui.emEspera:
            moveVel     = Vector3.Lerp(moveVel, moveDir, TRANSICAO_DA_VELOCIDADE * Time.deltaTime);
            r2.velocity = VEL_MOVIMENTO * moveVel;

            FlipDirection.Flip(transform, moveVel.x);
            break;

        case EstadoDaqui.posicionandoParaAtirar:
            tempoDecorrido += Time.deltaTime;
            moveVel         = Vector3.Lerp(moveVel, moveDir, TRANSICAO_DA_VELOCIDADE * Time.deltaTime);

            FlipDirection.Flip(transform, moveVel.x);

            r2.velocity = VEL_MOVIMENTO * moveVel;

            if (tempoDecorrido > INTERVALO_DE_TIRO)
            {
                RaycastHit2D hit = Physics2D.Linecast(transform.position, GameController.g.Manager.transform.position, 511);

                if (!hit)
                {
                    tempoDecorrido = 0;
                    estado         = EstadoDaqui.telegrafando;

                    Telegrafar(charPos);
                }
                else
                {
                    moveDir        = (transform.position - charPos).normalized;
                    estado         = EstadoDaqui.emEspera;
                    tempoDecorrido = 0;
                    Invoke("VerifiquePosicionamento", TEMPO_NA_ESPERA);
                }
            }
            break;

        case EstadoDaqui.telegrafando:
            tempoDecorrido += Time.deltaTime;
            moveVel         = Vector3.Lerp(moveVel, Vector3.zero, TRANSICAO_DA_VELOCIDADE * Time.deltaTime);
            r2.velocity     = moveVel;

            //FlipDirection.Flip(transform, moveVel.x);

            if (tempoDecorrido > TEMPO_TELEGRAFANDO)
            {
                RequestAction(charPos);
            }
            break;

        case EstadoDaqui.posicionandoEvasivamente:
            moveVel     = Vector3.Lerp(moveVel, moveDir, TRANSICAO_DA_VELOCIDADE * Time.deltaTime);
            r2.velocity = VEL_MOVIMENTO * moveVel;

            FlipDirection.Flip(transform, moveVel.x);

            break;
        }
    }