Наследование: MonoBehaviour
Пример #1
0
 void MakeSingiton()
 {
     if (!instance)
     {
         instance = this;
     }
 }
Пример #2
0
 void Start()
 {
     RespawnTrigger         = GetComponent <RespawnTrigger>();
     playerMove             = GetComponent <PlayerMovement>();
     playerJump             = GetComponent <PlayerJump>();
     RespawnTrigger.OnMove += Move;
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        if (playerState.IsEnabled())
        {
            float moveSpeed = maxMoveSpeed;
            if (slowed)
            {
                moveSpeed /= 2;
            }
            playerJump = this.GetComponentInChildren <PlayerJump>();
            Vector3 newVelocity = rigid.velocity;

            //Horizontal
            float vel = Input.GetAxis("Horizontal") * moveSpeed;
            if (Mathf.RoundToInt(vel) != 0)
            {
                newVelocity.x += vel;
                if (vel > 0 && newVelocity.x > moveSpeed)
                {
                    newVelocity.x = moveSpeed;
                }
                else if (vel < 0 && newVelocity.x < -1 * moveSpeed)
                {
                    newVelocity.x = -moveSpeed;
                }
                rigid.velocity = newVelocity;
            }
            else if ((playerJump.IsGrounded() && !playerState.IsFlying()) || (!playerJump.IsGrounded() && playerJump.IsStillJumped()))
            {
                rigid.velocity = new Vector3(0, rigid.velocity.y);
            }
        }
    }
Пример #4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        PlayerJump playerJump = other.gameObject.GetComponent <PlayerJump> ();

        playerJump.StartCoroutine("Boost");
        Destroy(gameObject);
    }
Пример #5
0
 //Cache currently used scripts to access as components
 private void Awake()
 {
     _movement = GetComponent <PlayerMovement>();
     _jumping  = GetComponent <PlayerJump>();
     _dash     = GetComponent <PlayerDash>();
     _attack   = GetComponent <PlayerAttack>();
 }
Пример #6
0
    // Update is called once per frame
    //TODO update states so that you can only morphball in mid air
    void LateUpdate()
    {
        if (isEnabled)
        {
            playerJump = GetComponentInChildren <PlayerJump>();
            if (standing && Input.GetKeyDown(KeyCode.DownArrow) && playerInventory.HasMorphBall() && (playerJump.IsGrounded() || playerInventory.HasTuckBall()))
            {
                Standing.SetActive(false);
                Morphed.SetActive(true);
                standing = false;
            }

            if (!standing && (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.X)))
            {
                if (!Physics.Raycast(transform.GetChild(1).transform.position, Vector3.up, 0.75f))
                {
                    Standing.SetActive(true);
                    Morphed.SetActive(false);
                    StartCoroutine(SetStanding());
                }
            }

            shooting = Input.GetKeyDown(KeyCode.Z);
        }

        running = rigid.velocity.x != 0;
    }
Пример #7
0
 /// <summary>
 /// Verifica qual método deve ser adicionado e / ou removido do  playerJump.
 /// </summary>
 private void PlayerJumpCheck()
 {
     if (state == State.wall)
     {
         // Adiciona WallJump e remove GroundJump do playerJump.
         if (!ContainsMethod("Wall"))
         {
             playerJump += WallJump;
         }
         if (ContainsMethod("Ground"))
         {
             playerJump -= GroundJump;
         }
     }
     else
     {
         //O oposto para qualquer outra situação
         if (ContainsMethod("Wall"))
         {
             playerJump -= WallJump;
         }
         if (!ContainsMethod("Ground"))
         {
             playerJump += GroundJump;
         }
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        tag    = "Player";
        health = GetComponent <Health>();
        health.EventTakeDamage   += OnTakeDamage;
        health.EventReciveHealth += OnReciveHealth;
        health.EventDeath        += OnDeath;

        firstPersonCamera = GetComponent <FirstPersonCamera>();
        normalAttack      = GetComponentInChildren <Weapon>();
        movement          = GetComponent <Movement>();
        jump      = GetComponent <PlayerJump>();
        command   = GetComponent <PlayerCommand>();
        skillTree = GetComponent <SkillTree>();

        drone = FindObjectOfType <DroneAi>();

        virusData = GetComponent <PlayerVirusData>();

        PlayerVirusData.OnResourceChanged += PlayerVirusData_OnResourceChanged;

        UpdateHealthText();
        ResourceText.text = virusData.ToString();
        flashBaseColor    = flashImage.color;
    }
Пример #9
0
 void MakeInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #10
0
 private void Awake()
 {
     jump     = GetComponent <PlayerJump>();
     movement = GetComponent <PlayerMovement>();
     props    = GetComponent <Player>();
     rb       = GetComponent <Rigidbody2D>();
 }
Пример #11
0
 private void Awake()
 {
     playerMoveScript    = GetComponent <PlayerLeftRightMove>();
     playerJumpScript    = GetComponent <PlayerJump>();
     playerJetJumpScript = GetComponent <PlayerJetJump>();
     playerFlyScript     = GetComponent <PlayerFly>();
 }
Пример #12
0
    // Start is called before the first frame update
    void Start()
    {
        move       = GetComponent <PlayerMove>();
        jump       = GetComponent <PlayerJump>();
        climb      = GetComponent <PlayerClimb>();
        playerMask = GetComponent <Masks>();
        playerItem = GetComponent <Item>();

        maskController = FindObjectOfType <MaskController>();
        inventory      = FindObjectOfType <Inventory>();
        speech         = FindObjectOfType <SpeechScript>();
        anim           = GetComponent <Animator>();
        grapple        = FindObjectOfType <GrapplingHook>();


        hasJumped     = false;
        hasWallJumped = false;
        isClimbing    = false;
        isZipping     = false;
        moving        = true;
        launched      = false;
        hasRune       = false;

        GetComponent <DistanceJoint2D>().enabled = false;
        maskInventory = new List <string>();
        itemInventory = new List <string>();

        maskCounter = 0;
        itemCounter = 0;

        knockbackCount = knockbackLength;
    }
Пример #13
0
 void Awake()
 {
     _inputs         = new PlayerInput();
     _playerMovement = new PlayerMovement(_inputs, _playerRb, _playerAnimator, _movementSpeed);
     _playerJump     = new PlayerJump(_playerRb, _playerAnimator, _groundCheck, _jumpPower);
     _playerCombat   = new PlayerCombat(_swordParent, _playerAnimator);
 }
Пример #14
0
 // Sets up initial movement mode
 private void SetUpMovements()
 {
     playerJump         = GetComponent <PlayerJump>();
     playerFly          = GetComponent <PlayerFly>();
     playerJump.enabled = true;
     playerFly.enabled  = false;
 }
Пример #15
0
    public void LogPlayerJump(Vector3 position, int controller)
    {
        string     time          = GetTime();
        PlayerJump newPlayerJump = new PlayerJump(position, controller);

        AppendToFile(LogPath, ",", "JUMP", time, position.x.ToString(), position.y.ToString(), controller.ToString());
    }
Пример #16
0
 void Start()
 {
     status      = GetComponent <PlayerStatus>();
     jump        = GetComponent <PlayerJump>();
     rigidBody2D = GetComponent <Rigidbody2D>();
     input       = GameObject.Find("InputManager").GetComponent <InputManager>();
 }
Пример #17
0
 void Start()
 {
     pm = GetComponent <PlayerMovement>();
     fc = GetComponent <FlipCharacter>();
     pj = GetComponent <PlayerJump>();
     bs = GetComponent <BulletSpawn>();
 }
Пример #18
0
 private void SetInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #19
0
 void Awake()
 {
     homePos       = transform.position;
     myJelly       = GetComponent <JellySprite>();
     myJump        = GetComponent <PlayerJump>();
     playerManager = FindObjectOfType <PlayerManager>();
 }
Пример #20
0
    void Start()
    {
        movScript    = FindObjectOfType <Movimentacao>();
        combosScript = FindObjectOfType <Combos>();
        dashScript   = FindObjectOfType <dashMove>();
        jumpScript   = FindObjectOfType <PlayerJump>();
        pauseScript  = FindObjectOfType <pauseInGame>();

        //CHAMAR TRANSIÇÃO
        transicaoParaODia = FindObjectOfType <TransicaoParaODia>();
        if (SceneManager.GetActiveScene().name == "CenaFinal")
        {
            GetComponent <Animator>().SetBool("bCenaFinal", true);

            if (GetComponent <Animator>().GetInteger("countStand") == 0)
            {
                StartCoroutine(waitStand());
            }

            GetComponent <Animator>().SetBool("bStretch", true);
        }
        else
        {
            GetComponent <Animator>().SetBool("bArtesFinalizacao", false);
        }
        fadeScript = FindObjectOfType <Fade>();
    }
Пример #21
0
 // Start is called before the first frame update
 void Start()
 {
     anim = GetComponent <Animator>();
     player_collisions = GetComponentInParent <PlayerCollisions>();
     rb2d        = GetComponentInParent <Rigidbody2D>();
     player_jump = GetComponentInParent <PlayerJump>();
 }
 // Start is called before the first frame update
 void Start()
 {
     gm          = gameManager.GetComponent <GameManager>();
     pj          = this.GetComponent <PlayerJump>();
     animator    = GetComponent <Animator>();
     audioSource = GetComponent <AudioSource>();
 }
Пример #23
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #24
0
 void Instances()
 {
     if (instan == null)
     {
         instan = this;
     }
 }
Пример #25
0
    public void JumpTo(Lane targetLane)
    {
        Vector3 targetPosition;

        if (targetLane != null)
        {
            targetPosition    = targetLane.GetJumpDestinationFrom(transform.position);
            targetPosition.z += currentSpeed * jumpDuration;
            KillEnemyAtJumpDestination(targetLane, targetPosition);
        }
        else
        {
            // Temp
            targetPosition    = transform.position + Vector3.right * 3f;
            targetPosition.z += currentSpeed * jumpDuration;
        }

        currentJumpAnimation = new PlayerJump(transform, targetPosition, jumpPower, jumpDuration)
                               .OnComplete(() =>
        {
            currentJumpAnimation = null;
            isJumping            = false;

            representation.location.laneA = targetLane;
            representation.location.laneB = null;
            representation.location.isMovingBetweenLanes = false;
            representation.location.isAboveLane          = false;
        });

        isJumping = true;
        wasJumpPressedDuringJump = false;
        previousJumpStartTime    = Time.unscaledTime;
        if (currentPlatformRepresentation != null)
        {
            previousPlatform = currentPlatformRepresentation;
        }
        representation.location.laneB = targetLane;
        representation.location.isMovingBetweenLanes = currentLane && currentLane != targetLane;
        representation.location.isAboveLane          = true;

        PlayJumpSound();

        if (targetLane == currentLane.leftNeighbor)
        {
            animator.SetTrigger("Jump_L");
        }
        else if (targetLane == currentLane.rightNeighbor)
        {
            animator.SetTrigger("Jump_R");
        }
        else if (targetLane == currentLane)
        {
            animator.SetTrigger("Jump_F");
        }
        else
        {
            animator.SetTrigger("Jump_R");  // TEMP. Jump to a null lane is right by default.
        }
    }
    private IEnumerator Show()
    {
        cameraAnimator.GetComponent <CameraZoom>().enabled = false;

        #region Disable player scripts:
        GameObject player = GameObject.FindWithTag("Player");
        weapon         = player.GetComponent <Weapon>();
        playerMovement = player.GetComponent <PlayerMovement>();
        playerJump     = player.transform.Find("JumpTrigger").GetComponent <PlayerJump>();

        weapon.enabled         = false;
        playerMovement.enabled = false;
        playerJump.enabled     = false;
        yield return(new WaitForSeconds(1));        // Wait for end of "scene change effect".

        #endregion Disable player scripts.

        #region Show the whole level if is not showed:
        skipInfoAnimator.Play("Start", 0, 0);         // Show skip info text.
        changeCamera = false;
        if (cameraAnimator.GetCurrentAnimatorStateInfo(0).IsName("FollowPlayer"))
        {
            changeCamera = true;
            cameraAnimator.Play("ShowLevel", 0, 0);
        }
        yield return(new WaitForSeconds(2));

        #endregion Show the whole level if is not showed.

        #region First dimension transition effect & sound:
        panel_OtherDimensionTransition.SetActive(true);
        AudioSource audio = GetComponent <AudioSource>();
        audio.Play();
        yield return(new WaitForSeconds(0.1665f));        // Half time of transition effect.

        #endregion First dimension transition effect & sound.

        #region Add masks to the list and set them active:
        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject mask = transform.GetChild(i).gameObject;
            masksList.Add(mask);
            mask.SetActive(true);
        }
        yield return(new WaitForSeconds(3));

        #endregion Add masks to the list and set them active.

        #region Second dimension transition effect & sound:
        panel_OtherDimensionTransition.SetActive(false);         // Turn off and on to repeat the animation.
        panel_OtherDimensionTransition.SetActive(true);
        audio.Play();
        yield return(new WaitForSeconds(0.1665f));        // Half time of transition effect.

        #endregion Second dimension transition effect & sound.

        backToNormalCoroutine = StartCoroutine(BackToNormal(false));
        showCoroutine         = null;
    }
 void Start()
 {
     rb           = GetComponent <Rigidbody>();
     playerInputs = GetComponent <PlayerInputs>();
     cf           = GetComponent <ConstantForce>();
     playerJump   = GetComponent <PlayerJump>();
     playerData   = GetComponent <PlayerData>();
 }
Пример #28
0
    /*
     * public GameManager theGameManager;
     *
     * public Transform playerDestructionPoint;
     *
     * public Transform collisionCheck;
     * public float collisionCheckRadius;
     * public LayerMask whatIsBumper;
     * private bool collided;
     */

    void Start()
    {
        myRigidbody = GetComponent <Rigidbody2D> ();

        myPlayerJump = GetComponent <PlayerJump> ();

        myAnimator = GetComponent <Animator> ();
    }
Пример #29
0
    void Start()
    {
        m_script = this;

        m_rb = GetComponent <Rigidbody>();

        m_jumpForce = m_jumpForceBase;
    }
Пример #30
0
 void Start()
 {
     movement    = GetComponent <PlayerMovement>();
     jump        = GetComponent <PlayerJump>();
     groundCheck = GetComponent <GroundCheck>();
     grab        = GetComponent <PlayerGrab>();
     anim        = GetComponent <Animator>();
 }
	// Use this for initialization
	void Start () {
		animationScript = GetComponent<PlayerAnimation> ();
		jumpScript = GetComponent<PlayerJump> ();
		localSpriteRenderer = GetComponent<SpriteRenderer> ();
		scoreScript = GetComponent<TheScoreSystem> ();
		currentHealth = maxHealth;

		healthUIScript = gameUI.GetComponent<UIHealth> ();
	}
Пример #32
0
    protected override void NeedToAwake()
    {
        figureData = GetComponent<FigureData>();

        if(gameObject.GetComponents<FigureMove>() != null)
            figureMove = GetComponent<FigureMove>();

        if(gameObject.GetComponent<PlayerJump>() != null)
            playerJump = GetComponent<PlayerJump>();
        SecNeedToAwake ();
    }
Пример #33
0
	void Start(){
		jumpScript = GetComponent<PlayerJump> ();
	}
Пример #34
0
    // Use this for initialization
    void Start()
    {
        //Initialise player animator
        anim = GetComponent<Animator>();

        //Initialise timer
        meleeTimer = meleeTimerReset;

        //Obtain the transform information of the Capsule Collider
        myCollider = transform.GetComponent<CapsuleCollider>();

        //Get Script components
        ladderClimb = GetComponent<PlayerLadderClimb>();
        controller = GetComponent<PlayerController>();
        jump = GetComponent<PlayerJump>();
    }
Пример #35
0
    // Use this for initialization
    void Start()
    {
        playerMove = GetComponent<PlayerMove>();
        playerJump = GetComponent<PlayerJump>();

        anim = GetComponent<Animator>();

        if(anim.layerCount ==2)
            anim.SetLayerWeight(1, 1);
    }
Пример #36
0
    // Use this for initialization
    void Awake()
    {
        if (FindRightControllers.Instance != null)
        {
            if (FindRightControllers.Instance.PlayerSlotsToRemember[Id] != -10)
            {
                PlayerController = (PlayerIndex)FindRightControllers.Instance.PlayerSlotsToRemember[Id];
                HasBeenChosen = true;
            }
        }
        else if (FindRightControllers.Instance != null)
            HasBeenChosen = false;
        else if (FindRightControllers.Instance == null)
            HasBeenChosen = true;

        pTran = transform;

        if(RendererObject != null)
        {
            if(RendererObject.GetComponent<SkinnedMeshRenderer>() != null)
                BodyRenderer = RendererObject.GetComponent<SkinnedMeshRenderer>();
            if(RendererObject.GetComponentsInChildren<MeshRenderer>() != null)
            {
                HelmetRenderers = RendererObject.GetComponentsInChildren<MeshRenderer>();
                originalHelmetColors = new Color[HelmetRenderers.Length];
                for(int i=0; i<originalHelmetColors.Length; i++)
                {
                    // removed by Gustav
                    //originalHelmetColors[i] = HelmetRenderers[i].material.color;
                }
            }
        }

        switch(Id)
        {
            case 0:
            if (FindRightControllers.Instance == null)
                PlayerController = PlayerIndex.One;
            pMat = Materials[0];
            break;
            case 1:
            if (FindRightControllers.Instance == null)
                PlayerController = PlayerIndex.Two;
            pMat = Materials[1];
            break;
            case 2:
            if (FindRightControllers.Instance == null)
                PlayerController = PlayerIndex.Three;
            pMat = Materials[2];
            break;
            case 3:
            if (FindRightControllers.Instance == null)
                PlayerController = PlayerIndex.Four;
            pMat = Materials[3];
            break;
        }
        if(BodyRenderer != null)
        {
            BodyRenderer.material.color = pMat.color;
            //BodyRenderer.materials[1].color = pMat.color;
            PlayerColor = pMat.color;
        }
        else
        {
            renderer.material = pMat;
            PlayerColor = pMat.color;
        }

        spawnPoints = new GameObject[SpawnPoints.transform.GetChildCount()];

        for(int i = 0; i<spawnPoints.Length; i++)
        {
              spawnPoints[i] = SpawnPoints.transform.GetChild(i).gameObject;
        }

        PlayerControllerState = GetComponent<ControllerState>();
        playerAim = GetComponent<PlayerAim>();
        playerMove = GetComponent<PlayerMove>();
        playerJump = GetComponent<PlayerJump>();

        SpawnZone = transform.Find("SpawnZone").gameObject;
        SpawnZone.SetActive(false);

        if (GetComponent<TargetIDColor>() == null)
            Debug.Log("ERROR - player needs to have TargetIDColor component " + gameObject);

        Name = gameObject.name;
        Points = 0;

        TotalMissionPlayerHasCompleted = 0;
    }
Пример #37
0
	// Use this for initialization
	void Start () {
		dropScript = GetComponent<Drop> ();
		jumpScript = GetComponent<PlayerJump> ();
	}
Пример #38
0
    // Use this for initialization
    void Start()
    {
        pTran = transform;

        playerScript = GetComponent<Player>();
        playerJump = GetComponent<PlayerJump>();

        startRotation = pTran.rotation;
    }
Пример #39
0
    // Use this for initialization
    void Start()
    {
        pTran = transform;
        aimPivotTran = transform.Find("AimPivot");
        aimTran = aimPivotTran.Find("Aim");
        chargeBar = aimTran.Find("ChargeBar");
        aimCross = pTran.Find("AimCross");

        chargeBar.forward = Vector3.forward;

        CurrentShotAmount = ShotAmount;

        playerScript = GetComponent<Player>();
        playerMove = GetComponent<PlayerMove>();
        playerJump = GetComponent<PlayerJump>();

        aimStartPos = aimTran.localPosition;
        aimStartRot = aimTran.rotation;
        aimStartScale = aimTran.localScale;
        aimTranStart = aimTran;
    }
Пример #40
0
	// Use this for initialization
	void Start () {
		theRigid = transform.parent.GetComponent<Rigidbody2D> ();
		jumpScript = transform.parent.GetComponent<PlayerJump> ();
	}
Пример #41
0
    void Start()
    {
        playerMove = GetComponent<PlayerMove>();
        playerJump = GetComponent<PlayerJump>();

        // initialising reference variables
        anim = GetComponent<Animator>();
        col = GetComponent<CapsuleCollider>();
        enemy = GameObject.Find("Enemy").transform;
        if(anim.layerCount ==2)
            anim.SetLayerWeight(1, 1);
    }