상속: MonoBehaviour
예제 #1
0
 // Use this for initialization
 void Start()
 {
     healthUI        = GameObject.FindGameObjectWithTag("HealthText");
     healthText      = healthUI.GetComponent <Text>();
     healthText.text = "Health: " + health;
     playerAudio     = GetComponent <PlayerAudio>();
 }
 // Use this for initialization
 private void Awake()
 {
     environment    = GameObject.FindWithTag("Environment");
     tilemap        = environment.GetComponentInChildren <Tilemap>();
     playerCharging = GetComponent <PlayerCharging>();
     playerAudio    = GetComponent <PlayerAudio>();
 }
    // Start is called before the first frame update
    void Start()
    {
        playerAudio = FindObjectOfType <PlayerAudio>();
        playerAudio.requestMalacodaClip();

        fire = gameObject.GetComponentInChildren <ParticleSystem>();
    }
예제 #4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        PlayerHealth playerHealth = collision.gameObject.GetComponent <PlayerHealth>();

        if (playerHealth != null)
        {
            if (ScoreManager.instance != null)
            {
                ScoreManager.instance.AddScore(scoreToAdd);
            }

            if (UIManager.instance != null)
            {
                UIManager.instance.GetUIAnimation().TriggerEnergyCollectedAnim();
            }

            playerHealth.AddEnergy(energyToAdd);
            // Get The Player Audio Reference To Trigger The Restored Sound Effect.
            PlayerAudio playerAudio = playerHealth.gameObject.GetComponent <PlayerAudio>();
            playerAudio.TriggerSoundEffect(playerAudio.healthSource, playerAudio.restoreClip);

            Instantiate(Resources.Load("Particles/Collectable Collected"), transform.position, transform.rotation, null);
            Destroy(this.gameObject);
        }
    }
예제 #5
0
    private Vector3 playerUpOrientation;    // modified by the player orientation function

    private void Awake()
    {
        playerUpOrientation   = Vector3.up;
        animatorBlendVariable = 0;

        playerSprite = gameObject.transform.GetChild(0).gameObject;

        ceilingCheck = gameObject.transform.Find("CeilingCheck").gameObject;
        groundCheck  = gameObject.transform.Find("GroundCheck").gameObject;
        //animator = GetComponent<Animator>();
        playerState = PlayerStates.idle;

        //Setting the blocks to false to allow inputs
        horizontalInputBlock = false;
        verticalInputBlock   = false;

        //Setting the jump button variables
        jumpButtonPresssed = false;
        jumpButtonReleased = true;

        playerAudio       = GetComponent <PlayerAudio>();
        playerAudioSource = GetComponent <AudioSource>();

        currentJumpDirection = Vector3.up;
    }
예제 #6
0
 void Awake()
 {
     rigidBody    = GetComponent <Rigidbody>();
     playerAudio  = GetComponent <PlayerAudio>();
     playerAttack = GetComponent <PlayerAttack>();
     playerStat   = GetComponent <PlayerStats>();
 }
예제 #7
0
 // Start is called before the first frame update
 void Start()
 {
     isDead      = false;
     rig         = GetComponent <Rigidbody2D>();
     playerAudio = GetComponent <PlayerAudio>();
     vida        = GetComponent <PlayerVidaHud>();
 }
        public void LoadPlayer()
        {
            var player = LoadAndInstaniate(Path.PLAYER_PREFAB, _parentManager.GetParnetTrans(ParentName.PlayerRoot));

            player.AddComponent <IgnorForce>();
            player.AddComponent <PlayerCollider>();

            IView            view      = player.AddComponent <PlayerView>();
            IPlayerBehaviour behaviour = new PlayerBehaviour(player.transform, ModelManager.Single.PlayerData);
            IPlayerAni       ani       = null;
            IPlayerAudio     audio     = new PlayerAudio(player.GetComponentInChildren <AudioSource>());

            Animator animator = player.GetComponent <Animator>();

            if (animator == null)
            {
                Debug.LogError("玩家预制上为发现动画组件");
            }
            else
            {
                ani = new PlayerAni(animator, new CustomAniEventManager(animator));
            }
            var entity = Contexts.sharedInstance.game.CreateEntity();

            entity.AddGamePlayer(view, behaviour, ani, audio);
            entity.AddGamePlayerAniState(PlayerAniIndex.IDLE);
            view.Init(Contexts.sharedInstance, entity);

            LoadTrails(player.transform, animator);
        }
예제 #9
0
 private void Start()
 {
     _playerAudio    = GetComponentInChildren <PlayerAudio>();
     _rigidbody      = GetComponent <Rigidbody>();
     _aim            = FindObjectOfType <AimCursor>();
     _playerAnimator = GetComponentInChildren <PlayerAnimatorController>();
 }
예제 #10
0
    //private float vignetteInit = 0f;
    private void Awake()
    {
        playerAudio = GetComponent <PlayerAudio>();
        //postProcessing = FindObjectOfType<Volume>().GetComponent<Animator>();
        volume = FindObjectOfType <Volume>();

        if (volume.profile.TryGet <LensDistortion>(out var lens))
        {
            distortion = lens;
        }
        if (volume.profile.TryGet <ColorAdjustments>(out var postColors))
        {
            colors = postColors;
        }
        if (volume.profile.TryGet <ChromaticAberration>(out var chrom))
        {
            chromatic     = chrom;
            chromaticInit = chrom.intensity.value;
        }

        /*
         * if (volume.profile.TryGet<Vignette>(out var vin))
         * {
         *  vignette = vin;
         *  vignetteInit = vin.intensity.value;
         * }*/
    }
예제 #11
0
    void Awake()
    {
        audios      = GetComponent <PlayerAudio>();
        unarmed     = gameObject.transform.Find(WeaponManager.Instance.WeaponPath() + "Unarmed");
        sword       = gameObject.transform.Find(WeaponManager.Instance.WeaponPath() + "Sword");
        heavySword  = gameObject.transform.Find(WeaponManager.Instance.WeaponPath() + "Sickle");
        bloodPotion = gameObject.transform.Find("M_ROOT/M_CENTER/BODY1/BODY2/R_CBONE/R_ARM1/R_ARM2/R_Hand/BloodPotion");
        bloodPotion.gameObject.SetActive(false);

        specialAttackParticle = gameObject.transform.Find("SpecialAttackArea/HitFX_Lightning/LightningMain").GetComponent <ParticleSystem>();

        WeaponManager.Instance.weaponList.Add(unarmed.gameObject);
        WeaponManager.Instance.weaponList.Add(sword.gameObject);
        WeaponManager.Instance.weaponList.Add(heavySword.gameObject);


        foreach (var pair in WeaponManager.Instance.weaponList)
        {
            pair.AddComponent <WeaponHit>();
            pair.SetActive(false);
        }

        PlayerAnimationManager.Instance.GetAnimation("Unarmed");
        WeaponManager.Instance.weaponList[0].SetActive(true);
    }
예제 #12
0
 void Start()
 {
     this.m_Animator         = this.GetComponent <Animator> ();
     this.m_Player           = this.GetComponent <Player> ();
     this.m_SpellClassToFire = this.GetComponent <PlayerInventory> ().m_ActiveSpellClass;
     this.m_playerAudio      = this.GetComponent <PlayerAudio> ();
 }
예제 #13
0
    protected virtual void Awake()
    {
        rigbod              = GetComponent <Rigidbody>();
        playerAudio         = GetComponent <PlayerAudio>();
        is_secondary_moving = false;

        stunned                = false;
        death_status           = false;
        attacking              = false;
        current_jump_cool_down = jump_cool_down;

        last_keypress = InputType.No_Press;

        stunned_counter = stunned_wait_timer;

        animator                 = GetComponentInChildren <Animator>();
        animator_2d              = transform.GetChild(1).GetComponent <Animator>();
        child                    = this.transform.GetChild(0).gameObject;
        player_camera            = Camera.main;
        retical                  = new GameObject("Reticle_" + this.gameObject.name);
        retical.transform.parent = transform;
        canvas                   = GameObject.Find("/SceneManagement/Canvas").GetComponent <Canvas>();
        ui_retical               = Instantiate(ui_retical_prefab);
        ui_retical.name          = "UI_Reticle_" + this.gameObject.name;
        ui_retical.transform.SetParent(canvas.transform, false);
        ui_retical.SetActive(true);
        player_collision = GetComponent <PlayerCollision>();

        animator.SetBool("landed", true);


        FindAnimationTimes();
        ResetAnimationState();
    }
예제 #14
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // get the player audio script
        playerAudio = animator.GetComponentInParent <PlayerAudio>();

        playerAudio.Footsteps.Play();
    }
    void Awake()
    {
		playerAudio = transform.parent.GetComponent<PlayerAudio>();
        jetpackParticles = transform.FindChild("Particle Emitter").GetComponent<ParticleSystem>();

		playerAnimPhotonView = GetComponent<PhotonView>();
    }
예제 #16
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Use"))
     {
         if (isWater) //Check is it Water
         {
             Drink(WaterAmount, this.gameObject.GetComponent <PlayerLiveStats>());
             if (PlayWaterSound == true) // Check if it includes water sound
             {
                 PlayerAudio audio = Player.gameObject.GetComponent <PlayerAudio>();
                 audio.PlaySound(audio.waterSound);
             }
         }
         if (isFood) //Check is it Water
         {
             Eat(FoodAmount, Player.gameObject.GetComponent <PlayerLiveStats>());
             if (PlayFoodSound == true) // Check if it includes food sound
             {
                 PlayerAudio audio = Player.gameObject.GetComponent <PlayerAudio>();
                 audio.PlaySound(audio.foodSound);
             }
         }
         this.gameObject.SetActive(false);
     }
     if (Input.GetKeyDown(KeyCode.F) && !craftMaterial)
     {
         this.gameObject.SetActive(false);
     }
 }
    void Awake()
    {
        playerAudio      = transform.parent.GetComponent <PlayerAudio>();
        jetpackParticles = transform.FindChild("Particle Emitter").GetComponent <ParticleSystem>();

        playerAnimPhotonView = GetComponent <PhotonView>();
    }
 void Awake()
 {
     playerMovement = GetComponent <PlayerMovement>();
     anim           = arms.GetComponent <Animator>();
     playerAudio    = GetComponentInChildren <PlayerAudio>(); //player audio is child of player
     lookRoot       = transform.GetChild(0);                  //look root is child of player
 }
예제 #19
0
    private void Awake()
    {
        m_audioSource = new AudioSource[m_audioClips.Length];
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        for (int i = 0; i < m_audioSource.Length; i++)
        {
            m_audioSource[i]             = gameObject.AddComponent <AudioSource>();
            m_audioSource[i].clip        = m_audioClips[i];
            m_audioSource[i].playOnAwake = false;
        }

        m_audioSource[0].loop = true;
        m_audioSource[1].loop = true;
        m_audioSource[0].Play();
        m_audioSource[1].Play();
    }
 void Start()
 {
     rb2d         = GetComponent <Rigidbody2D>();
     animator     = this.transform.parent.gameObject.GetComponent <Animator>(); // Animator er á foreldri svo dauði geti haft "relative position"
     audioManager = GetComponent <PlayerAudio>();
     enemyLayer   = LayerMask.NameToLayer("Enemy");
     playerHealth = GetComponent <PlayerHealth>();
 }
예제 #21
0
 private void GetReferences()
 {
     player                  = GetComponentInParent <Player>();
     rb2d                    = GetComponentInParent <Rigidbody2D>();
     animator                = GetComponentInParent <Animator>();
     playerAudio             = GetComponentInParent <PlayerAudio>();
     playerActionsController = GetComponentInParent <PlayerActionsController>();
 }
예제 #22
0
 void Start()
 {
     // Gets parent's gameObject
     this.Player      = gameObject.transform.parent.gameObject;
     this.ADSR        = this.Player.GetComponent <ADSRManager>();
     this.playerAudio = Player.GetComponent <PlayerAudio>();
     this.Body        = this.Player.GetComponent <Rigidbody2D>();
 }
예제 #23
0
 private void Start()
 {
     player       = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController2>();
     plAudio      = player.GetComponentInChildren <PlayerAudio>();
     normalSpeed  = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController2>().speedMov;
     speedReduced = normalSpeed * percentReducction;
     col          = GetComponent <Collider2D>();
 }
예제 #24
0
 void Start()
 {
     audioManager     = GetComponent <PlayerAudio>();
     playerController = GetComponent <PlayerController>();
     rb2d             = GetComponent <Rigidbody2D>();
     playerCollider   = GetComponent <BoxCollider2D>();
     playerAnimator   = this.transform.parent.gameObject.GetComponent <Animator>(); // Animator er á foreldri svo dauði geti haft "relative position"
 }
예제 #25
0
 private void Awake()
 {
     playerStats = GetComponent <PlayerStats>();
     playerAudio = GetComponent <PlayerAudio>();
     rigidbody   = GetComponent <Rigidbody>();
     playerIndex = GetComponent <PlayerStats>().playerIndex;
     currentAmmo = currentBullet.startAmmo;
 }
예제 #26
0
 void Start()
 {
     orientation = GlobalConsts.Orientation.RIGHT;
     sword.SetSide(GlobalConsts.Orientation.RIGHT);
     rb = GetComponent <Rigidbody> ();
     setSwordActive(false);
     playerAudio = gameObject.GetComponent <PlayerAudio>();
 }
예제 #27
0
    // Start is called before the first frame update
    void Start()
    {
        ghostDistance = GetComponent <GhostDistance>();

        targetObject         = GameObject.FindGameObjectWithTag("Player");
        playerAudio          = targetObject.GetComponent <PlayerAudio>();
        currentDistanceState = ghostDistance.Far;
    }
예제 #28
0
 // Use this for initialization
 void Start()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     playerHealth = player.GetComponent <PlayerHealth>();
     //monsterHealth = GetComponent<MonsterHealth>();
     anim        = GetComponent <Animator>();
     agent       = GetComponent <NavMeshAgent>();
     playerAudio = player.GetComponent <PlayerAudio>();
 }
예제 #29
0
 void Awake()
 {
     floorMask       = LayerMask.GetMask("Floor");
     anim            = GetComponent <Animator> ();
     playerRigidbody = GetComponent <Rigidbody> ();
     runCounter      = runTime;
     playerAudio     = GetComponent <PlayerAudio> ();
     playerHealth    = GetComponent <PlayerHealth> ();
 }
예제 #30
0
    // Use this for initialization
    void Start()
    {
        Player    = GameObject.Find("Player");
        PauseMenu = GameObject.Find("Pause Menu");

        PlayerMovementScript      = Player.GetComponent <PlayerMovement>();
        PlayerAudioMovementScript = Player.GetComponent <PlayerAudio>();
        PlayerRigidbody           = Player.GetComponent <Rigidbody>();
    }
예제 #31
0
 public void Awake()
 {
     _animator   = GetComponent <Animator>();
     playerGrab  = GetComponent <PlayerGrab>();
     rb          = GetComponent <Rigidbody2D>();
     coll        = GetComponent <BoxCollider2D>();
     playerAudio = GetComponent <PlayerAudio>();
     startScale  = transform.localScale;
 }
예제 #32
0
    protected virtual void Start()
    {
        audioSources = GetComponents<AudioSource>();
        animator = GetComponent<Animator>();
		fearMeter = GameObject.Find ("FearMeter").GetComponent<Slider> ();

        npc = GameObject.Find("PlayerCollider").GetComponent<NPCScript>();
		npcAudio = GameObject.Find("PlayerCollider").GetComponent<PlayerAudio>();

        // determine what floor we are on using elevation markers.
        if      (transform.position.y > GameObject.Find("2").transform.position.y) floor = 2;
        else if (transform.position.y > GameObject.Find("1").transform.position.y) floor = 1;
        else if (transform.position.y > GameObject.Find("G").transform.position.y) floor = 0;
        else floor = -1;
    }
예제 #33
0
    void Awake()
    {
        instance = this;
        ResetEvents();

        anim = GetComponent<Animator>();
        audio = GetComponent<PlayerAudio>();
        damageFlash = GetComponent<SpriteFlash>();
        feedback = GetComponent<PlayerForceFeedback>();
        health = GetComponent<PlayerHealth>();
        input = GetComponent<PlayerInput>();
        interaction = GetComponent<PlayerInteraction>();
        physics = GetComponent<PlayerPhysics>();
        weapon = GetComponent<PlayerWeapon>();

        meleeAttackBox = transform.FindChild("MeleeAttackBox").gameObject;
    }
예제 #34
0
 void Start()
 {
     data  = GameObject.Find("lvl_controller").GetComponent<DataController>();
     audio = GetComponent<PlayerAudio>();
 }
예제 #35
0
	void SetInitialReferences()
	{
		if (GameObject.Find("_GameManager").GetComponent<GameManager_Master>() != null)
		{
			gameManagerMaster = GameObject.Find("_GameManager").GetComponent<GameManager_Master>();
		}
		if (GetComponent<PlayerEffects>() != null)
		{
			effects = GetComponent<PlayerEffects>();
		}
		if (GetComponent<Player_Master>() != null)
		{
			playerMaster = GetComponent<Player_Master>();
		}

		playerRigidBody = GetComponent<Rigidbody>();
		playerCapsule = GetComponent<CapsuleCollider>();
		playerAnimator = GetComponent<Animator>();
		playerAudio = GetComponent<PlayerAudio>();
	}
예제 #36
0
        // Use this for initialization
        void Start()
        {
            status = GetComponent<PlayerStatus>();
            statePool = new PlayerStatePool();
            rb = GetComponent<Rigidbody>();
            col = GetComponent<CapsuleCollider>();
            audioScript = GetComponent<PlayerAudio>();
            crouching = false;
            grounded = true;
            movementState = statePool.GetState("IDLE");
            carryState = CarryState.NOT_CARRYING;

            directionVector = Vector3.zero;

            maxCrawlSpeed = maxSpeed / 2f;
            maxVelocityChange = 3f;
        }
예제 #37
0
        // Use this for initialization
        void Start()
        {
            PlayerStatus.playerCount++;
            controlState = ControlState.NOT_CONTROLLABLE;
            movement = GetComponent<PlayerMovementRB>();
            audioScript = GetComponent<PlayerAudio>();

            if (playerNumber <= 0 || playerNumber > 4)
            {
                Debug.LogError(this + ": playerNumber should be 1 to 4, was: " + playerNumber);
            }

            health = startingHealth;
            movement.SetPlayer(playerNumber);
        }
예제 #38
0
    private void Start()
    {
        enemy = GameObject.Find("Enemy").GetComponent<EnemyStats>()
                ?? (enemy = new EnemyStats());
        guiElements = this.gameObject.GetComponent<PlayerGUI>();
        playerDeathSound = GameObject.Find("PlayerDeathSound").GetComponent<PlayerAudio>();
        playerLevelUpSound = GameObject.Find("PlayerLevelUpSound").GetComponent<PlayerAudio>();

        SetStartingStats();
    }
예제 #39
0
    public void PlaySound(PlayerAudio.Sound sound)
    {
        if (audio == null) return;

        audio.Play(sound);
    }
	/*---------------------------------------------------- INITIALISATION ----------------------------------------------------*/

    public void Initialisation()
    {
        //Set manager script references
        if (GameObject.Find("GameManager") != null)
        {
            gameManagerPhotonView = GameObject.Find("GameManager").GetComponent<PhotonView>();
            powerManager = GameObject.Find("GameManager").GetComponent<PowerManager>();
        }

        else
            Debug.LogWarning("Could not find GameManager! Is there a GameManager in the scene?");

        gameMenuUI = GameObject.Find("GameMenuUI").GetComponent<GameMenuUI>();

        consoleCamera = transform.FindChild("ConsoleCamera").gameObject;
        groundCheckCollider = transform.FindChild("GroundCheck").GetComponent<BoxCollider2D>();
        wallCheckCollider = transform.FindChild("WallCheck").GetComponent<BoxCollider2D>();
        unpowerAllButton = GameObject.Find("Unpower All Button");

        physicalColliders = LayerMask.GetMask("Wall", "Door", "Platform", "InteriorDoor");

        //Initialise Player Stats
        playerStats = GetComponent<PlayerStats>();

        //Initialises Animator and Colliders.
        anim = transform.FindChild("Player Animation").GetComponent<Animator>();
        playerRigidbody = GetComponent<Rigidbody2D>();

        playerAnimPhotonView = transform.FindChild("Player Animation").GetComponent<PhotonView>();
        heartIconBehaviours = transform.FindChild("Player Animation").GetComponent<HeartIconBehaviours>();
        jetpackBehaviours = transform.FindChild("Player Animation").GetComponent<JetpackBehaviours>();
        print(playerAnimPhotonView.name + heartIconBehaviours.name + jetpackBehaviours.name);

        unpowerAllButton.GetComponent<Image>().enabled = false;
        unpowerAllButton.GetComponent<Button>().enabled = false;

        gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();

        Cursor.visible = false;
        GameObject.Find("GameManager").GetComponent<MouseBehaviours>().enabled = true;

        left = KeyCode.LeftArrow;
        right = KeyCode.RightArrow;
        up = KeyCode.UpArrow;
        W = KeyCode.W;
        A = KeyCode.A;
        D = KeyCode.D;
        E = KeyCode.E;

        playerCameras = new GameObject[3];
        for (byte counter = 0; counter < playerCameras.Length; counter++)
            playerCameras[counter] = transform.FindChild("Cameras").GetChild(counter).gameObject;

        playerAudio = GetComponent<PlayerAudio>();

        if (GameObject.Find("AudioManager"))
            audioManager = GameObject.Find("AudioManager").GetComponent<AudioManager>();

        dialogBox = GameObject.Find("DialogBoxText").GetComponent<DialogBox>();
    }
예제 #41
0
 void Start()
 {
     playerPhysics = GetComponent<Rigidbody>();
     tranformBody  = playerBody.GetComponent<Transform>();
     playerAudio   = playerBody.GetComponent<PlayerAudio>();
 }