Inheritance: MonoBehaviour
Example #1
0
 /// Awake is called when the script instance is being loaded.
 void Awake()
 {
     rb          = GetComponent <Rigidbody2D>();
     anim        = GetComponent <Animator>();
     playerSound = GetComponent <PlayerSound>();
     lm          = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <LevelManager>();
 }
Example #2
0
 private void PlayerInit()
 {
     if (!rigid)
     {
         rigid = GetComponent <Rigidbody>();
     }
     if (!invComponent)
     {
         invComponent = GetComponent <InventoryComponent> ();
     }
     if (!abilities)
     {
         abilities = GetComponent <PlayerAbilities> ();
     }
     if (!energy)
     {
         energy = GetComponent <PlayerEnergy> ();
     }
     if (!pointLight)
     {
         pointLight = GetComponent <Light> ();
     }
     if (!sound)
     {
         sound = GetComponent <PlayerSound> ();
     }
     if (!particles)
     {
         particles = GetComponent <PlayerParticles> ();
     }
 }
Example #3
0
 // Use this for initialization
 void Start()
 {
     target = GameObject.Find("Player").transform;               //Player의 Transform을 가져옴
     characterController = GetComponent <CharacterController>(); //캐릭터 컨트롤러를 가져옴
     playerState         = target.GetComponent <PlayerState>();  //Player State 가져옴
     playerSound         = target.GetComponent <PlayerSound>();  //Player Sound 가져옴
 }
Example #4
0
    IEnumerator StartAnimationSound()
    {
        bool m_one   = true;
        bool m_two   = false;
        bool m_three = false;

        while (playerOneAttack)
        {
            float animationTime = kohakuAnimation.GetCurrentAnimatorStateInfo(0).normalizedTime;

            if (animationTime >= 0.1f && animationTime <= 0.7f && m_one && kohakuAnimation.GetCurrentAnimatorStateInfo(0).IsName("Attack_1"))
            {
                m_one = false;
                m_two = true;
                PlayerSound.playSoundManagerCall().PlayAudio("attackSound", false, 0);
            }
            if (animationTime >= 0.3f && animationTime <= 0.7f && m_two && kohakuAnimation.GetCurrentAnimatorStateInfo(0).IsName("Attack_2"))
            {
                m_two   = false;
                m_three = true;
                PlayerSound.playSoundManagerCall().PlayAudio("attackSound", false, 0);
            }
            if (animationTime >= 0.3f && animationTime <= 0.7f && m_three && kohakuAnimation.GetCurrentAnimatorStateInfo(0).IsName("Attack_3"))
            {
                m_three = false;
                PlayerSound.playSoundManagerCall().PlayAudio("attackSound", false, 0);
            }
            yield return(new WaitForSeconds(Time.deltaTime));
        }
        yield return(null);
    }
Example #5
0
    void PlayerJump()
    {
        if (!CheckStatus(PlayerState.Player_Jump) && !CheckStatus(PlayerState.Player_DoubleJump))
        {
            if (CheckStatus(PlayerState.Player_Idle) || CheckStatus(PlayerState.Player_Run))
            {
                PlayerSound.playSoundManagerCall().PlayAudio("jumpSound", false, 0);
                charactorMoveValue.charactorHeight = charactorMoveValue.jumpPower * magnification;
                playerStats.CurPlayerStatus(PlayerState.Player_Jump);
            }
        }
        else if (!CheckStatus(PlayerState.Player_DoubleJump) && CheckStatus(PlayerState.Player_Jump))
        {
            PlayerSound.playSoundManagerCall().PlayAudio("doubleJumpSound", true, 0);
            charactorMoveValue.charactorHeight = charactorMoveValue.jumpPower * magnification;
            playerStats.CurPlayerStatus(PlayerState.Player_DoubleJump);
            jumpEffect.Play();
        }

        if (stopPlayer)  //만약 플레이어가 매달려있는(hang)상태면 jump상태로 바꾸고 hang상태를 해제한다
        {
            charactorMoveValue.charactorHeight = charactorMoveValue.jumpPower * magnification;
            playerStats.CurPlayerStatus(PlayerState.Player_Jump);
            stopPlayer = false;
        }
    }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #7
0
 void Start()
 {
     myRB        = GetComponent <Rigidbody>();
     myAnim      = GetComponent <Animator>();
     playerSound = GetComponent <PlayerSound>();
     health      = GetComponent <Health>();
     uiManager   = FindObjectOfType <UIManager>();
 }
Example #8
0
 void PlayerSlide()
 {
     if (CheckStatus(PlayerState.Player_Run))
     {
         PlayerSound.playSoundManagerCall().PlayAudio("playerSlide", false, 0.4f);
         playerStats.CurPlayerStatus(PlayerState.Player_SlideStep);
     }
 }
Example #9
0
 private void PlayAnimationWithTimer()
 {
     if (PlayerSound.clip != null)
     {
         PlayerSound.Play();
     }
     AnimationPlayTimer.StartTimer(AnimationTimer);
 }
Example #10
0
 private void Start()
 {
     _playerStatus    = GetComponent <PlayerStatus>();
     _playerSound     = GetComponent <PlayerSound>();
     _currHPPosionCnt = GameManager.instance.playerData.HPPosionCnt;
     PlayerUICtrl.UI.SetItemCnt(_currHPPosionCnt);
     _recoveryEffect.Stop();
 }
Example #11
0
    void Start () {
        playerCam = GetComponent<PlayerController>().GetPlayerCam();
        playerSound = GetComponent<PlayerSound>();
        playerStats = GetComponent<PlayerStats>();
        playerUI = GetComponent<PlayerUI>();

        shotInterval = playerWeapon.fireRate;
    }
    void Awake()
    {
        if (Instance != this)
            Instance = this;

        if (PlayerAudio == null)
            PlayerAudio = GetComponentInChildren<AudioSource>();
    }
Example #13
0
 void Awake()
 {
     this.animator = gameObject.GetComponent <Animator>();
     this.rigid2D  = gameObject.GetComponent <Rigidbody2D>();
     this.sound    = gameObject.GetComponent <PlayerSound>();
     this.name     = gameObject.name;
     jumpCount     = 0;
 }
Example #14
0
 void Start()
 {
     anim    = GetComponent <Animator>();
     plat    = GetComponent <PlatformerCollision>();
     pls     = GetComponent <PlayerSound>();
     plygrab = GetComponent <PlayerGrab>();
     FindWaters();
 }
Example #15
0
 private void PlayAnimationWithTimer()
 {
     if (PlayerSound.clip != null)
     {
         PlayerSound.Play();
     }
     Debug.Log(AnimationTimer);
     AnimationPlay.StartTimer(AnimationTimer);
 }
 public void Init()
 {
     body        = GetComponent <Rigidbody2D>();
     animator    = GetComponent <Animator>();
     groundCheck = GetComponent <PlayerOnGroundCheck>();
     timer       = GetComponentInChildren <PlayerTimer>();
     sound       = GetComponentInChildren <PlayerSound>();
     SetCollisionEnabled(false);
 }
Example #17
0
    void Start()
    {
        soundManager = GetComponent <PlayerSound>();

        if (startPoint != null)
        {
            transform.position = startPoint.position;
        }
    }
Example #18
0
    /// <summary>
    /// Update is called every frame, if the MonoBehaviour is enabled
    /// <see cref="Unity Documentation">
    /// </summary>
    protected virtual void Update()
    {
        // Cycle through each absorbable light source being touched by this GameObject
        for (int i = 0; i < absorbableLightDetector.NeighbourCount; i++)
        {
            GameObject absorbableLight = absorbableLightDetector.GetNeighbour(i);
            if (absorbableLight == null)
            {
                continue;
            }

            LightSource otherLightSource = absorbableLight.GetComponentInParent <LightSource>();
            if (otherLightSource == null)
            {
                continue;
            }

            // If this GameObject can absorb the touched light source,
            // Transfer light energy from the other light source to this one
            if (CanAbsorb(otherLightSource))
            {
                if (this is Player)
                {
                    PlayerSound playerSound = GetComponent <PlayerSound>();
                    playerSound.EatSound();
                }
                LightEnergy lightEnergyToAbsorb = otherLightSource.LightEnergy;

                // Calculate the amount of light to absorb from the other light source
                float lightToAbsorb = absorptionRate * Time.deltaTime;

                // If the player was hit
                if (otherLightSource is Player)
                {
                    if (this is AbstractFish)
                    {
                        // Absorb a certain amount of light from the player to the fish
                        AbstractFish fish = (AbstractFish)this;
                        lightToAbsorb = fish.damageInflicted;
                    }

                    // Debug.Log("Absorb " + lightToAbsorb + " from player");

                    // Knockback the player away from the enemy fish
                    otherLightSource.Knockback(this);
                }

                // Transfer light energy from the other light source to this one
                float lightAbsorbed = lightEnergyToAbsorb.Deplete(lightToAbsorb);
                lightEnergy.Add(lightAbsorbed);

                // Inform subscribers that this light source consumed another light source.
                ConsumedLightSource(otherLightSource);
            }
        }
    }
Example #19
0
    void Awake()
    {
        playerSound    = GetComponent <PlayerSound>();
        animator       = GetComponent <Animator>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        rigidbody     = GetComponent <Rigidbody2D> ();
        playerPowerUp = GetComponent <PlayerPowerUp>();
        gravity       = -Physics2D.gravity.y;
    }
Example #20
0
 /*
  * Register that we've hit the player
  */
 public void OnCollisionEnter(Collision other)
 {
     if (other.collider.tag == "Player")
     {
         PlayerSound sound = other.collider.transform.parent.gameObject.GetComponent("PlayerSound") as PlayerSound; // tell my playersound to play the bad sound
         sound.PlayBadSound();
         GameManager.DecrementScore();
         Destroy(gameObject);
     }
 }
Example #21
0
    private void Awake()
    {
        if (instance)
        {
            DestroyImmediate(this);
            return;
        }

        instance = this;
    }
Example #22
0
        private void Start()
        {
            _advCol = GetComponent <AdvPlayerCollider>();
            _rb     = GetComponent <Rigidbody2D>();
            _sounds = GetComponentInChildren <PlayerSound>();

            if (_sounds == null)
            {
                Debug.LogError("Error: PlayerSound.cs is missing on the " + gameObject.name + " gameObject.");
            }
        }
Example #23
0
 void Start()
 {
     if (World.i.SpawnPoint != Vector3.zero)
     {
         transform.position = World.i.SpawnPoint;
     }
     //targetRotation = transform.rotation;
     originalRotation = transform.rotation;
     _rigidbody       = GetComponent <Rigidbody>();
     playerSound      = GetComponent <PlayerSound>();
 }
Example #24
0
 private void Awake()
 {
     if (self == null)
     {
         self = this;
     }
     else if (self != this)
     {
         Destroy(gameObject);
     }
 }
    // Use this for initialization
    void Start()
    {
        hit = UnityEngine.Resources.Load <GameObject>("HitBall");
        if (!_plyAnim)
        {
            Debug.LogError("SwordCollisionHandler :: F**k u bitch.");
        }

        _plySound = _plyAnim.GetComponent <PlayerSound>();
        box       = GetComponent <BoxCollider>();
    }
Example #26
0
    void MoveBike(float bikeHorizontal, float bikeVertical)
    {
        fWheel.motorTorque = bikeVertical * bikeSpeed;
        rWheel.motorTorque = bikeVertical * bikeSpeed;
        fWheel.steerAngle  = bikeHorizontal * bikeRotAngle;
        rWheel.steerAngle  = bikeHorizontal * bikeRotAngle;

        if (bikeVertical != 0)
        {
            PlayerSound.playSoundManagerCall().PlayAudio("bikeDrive", false, 0);
        }
    }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.LogError("More than one instaance of PlayerSound. Deleting Object");
         Destroy(gameObject);
     }
 }
Example #28
0
    // Start is called before the first frame update
    void Awake()
    {
        currHealth = maxHealth;
        healthBar  = GameObject.FindGameObjectWithTag("HealthBar").GetComponent <VitalityBar>();

        currSatiety = maxSatiety;
        hungerBar   = GameObject.FindGameObjectWithTag("HungerBar").GetComponent <VitalityBar>();

        controller = GetComponent <PlayerController>();

        playerSound = GetComponent <PlayerSound>();
    }
Example #29
0
 /// <summary>
 /// Initialize Player components
 /// <see cref="Unity Documentation">
 /// </summary>
 protected override void Awake()
 {
     base.Awake();
     this.controllerRumble         = GetComponent <ControllerRumble>();
     this.playerSound              = GetComponent <PlayerSound>();
     this.movement                 = new PlayerMovement(movementBean, this.Transform, this.Rigidbody, this.LightEnergy);
     this.lightToggle              = new PlayerLightToggle(this.Transform.Find("LightsToToggle").gameObject, this, lightToggleBean);
     this.flareControl             = new PlayerSpawnFlare(flareBean, this, controllerRumble);
     this.movementBean.DefaultDrag = Rigidbody.drag;
     this.isDead = false;
     this.isSafe = true;
 }
    void Awake()
    {
        if (Instance != this)
        {
            Instance = this;
        }

        if (PlayerAudio == null)
        {
            PlayerAudio = GetComponentInChildren <AudioSource>();
        }
    }
Example #31
0
        public main()
        {
            //===================================//
            //            SoundSystem            //
            //===================================//
            Exports.Add("Play", new Action <string, float>((name, volume) => {
                PlayerSound.Play(name, volume);
            }));

            Exports.Add("PlayPos", new Action <string, float, Vector3>((name, volume, pos) => {
                PlayerSound.Play(name, volume, pos);
            }));

            Exports.Add("PlayUrl", new Action <string, string, float>((name, url, volume) => {
                PlayerSound.PLayUrl(name, url, volume);
            }));

            Exports.Add("PlayUrlPos", new Action <string, string, float, Vector3>((name, url, volume, pos) => {
                PlayerSound.PLayUrl(name, url, volume, pos);
            }));

            Exports.Add("Pause", new Action <string>((name) => {
                PlayerSound.Pause(name);
            }));

            Exports.Add("Stop", new Action <string>((name) => {
                PlayerSound.Stop(name);
            }));

            Exports.Add("Resume", new Action <string>((name) => {
                PlayerSound.Resume(name);
            }));

            Exports.Add("Distance", new Action <string, int>((name, disc) => {
                PlayerSound.Distance(name, disc);
            }));

            Exports.Add("Position", new Action <string, Vector3>((name, pos) => {
                PlayerSound.Position(name, pos);
            }));
            //===================================//
            //            MoneySystem            //
            //===================================//
            Exports.Add("getDirtyMoney", new Func <int>(PlayerMoney.getDirtyMoney));
            Exports.Add("getBankMoney", new Func <int>(PlayerMoney.getBankMoney));
            Exports.Add("getMoney", new Func <int>(PlayerMoney.getMoney));
            //===================================//
            //             JobSystem             //
            //===================================//
            Exports.Add("getJob", new Func <string>(PlayerJob.getJobName));
            Exports.Add("getGrade", new Func <string>(PlayerJob.getJobGrade));
        }
 void Start()
 {
     this.timer = cooldownTime;
     this.lightSource = GetComponent<LightSource>();
     this.controllerRumble = GetComponent<ControllerRumble>();
     this.rigidbody = GetComponent<Rigidbody>();
     player = GameObject.FindWithTag("Player").transform;
     playerSound = player.GetComponent<PlayerSound>();
     GameObject mainCamera = GameObject.Find("Main Camera");
     if (mainCamera != null)
     {
         this.smoothCamera = mainCamera.GetComponent<SmoothCamera>();
     }
 }
    void Start()
    {
        ink = inkObject.GetComponent<ParticleSystem>();
        ink.enableEmission = false;
        jumpReleased = true;
        direction = Vector3.zero;
        wallJumpDirection = Vector3.zero;
        jumpPressed = false;
        controller = GetComponent<CharacterController>();
        anim = GetComponent<Animator>();
        health = PlayerHealth.instance;
        playerInk = PlayerInk.instance;
        sound = PlayerSound.instance;

        jumping = false;
        grounded = false;
        stuck = false;
        stickiness = 1;
    }
    void Start()
    {
        textBoxReference [0] = GameObject.Find ("TextBox_Android");
        textBoxReference [1] = GameObject.Find ("TextBox");

        playerSound = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerSound>();

        if (GameController.instance.isAndroidVersion) {
            interactButton = GameObject.Find ("InteractionButton").GetComponent<BubbleBehaviour> ();
            textBox = textBoxReference[0].GetComponent<FadeInFadeOut>();
            textBoxReference[1].SetActive(false);
        } else {
            textBox = textBoxReference[1].GetComponent<FadeInFadeOut>();
            textBoxReference[0].SetActive(false);
        }

        feedText = textBox.transform.GetChild(0).GetComponent<FeedTextFromObject> ();
    }
    /// <summary>
    /// Initializes Player components
    /// </summary>
    protected override void Awake()
    {
        base.Awake(); // call parent LightSource Awake() first
        if (playerInstance != null && playerInstance != this)
        {
            GameObject.Destroy(this.gameObject);
        }
        else
        {
            DontDestroyOnLoad(this.gameObject);
            playerInstance =  this;
        }

        this.movement = new PlayerMovement(massEjectionTransform, lightBallPrefab, thrustForce, changeDirectionBoost, thrustEnergyCost, brakeDrag, this.Transform, this.Rigidbody, this.LightEnergy, this.jetFuelEffect, this.rotationSpeed);
        this.lightToggle = new PlayerLightToggle(this.Transform.Find("LightsToToggle").gameObject, defaultLightStatus, this, minimalEnergyRestrictionToggleLights, propulsionLightRange);
        this.materials = new MaterialExtensions();

        this.defaultDrag = Rigidbody.drag;
        this.isDead = false;
        this.isSafe = true;
        this.controllerRumble = GetComponent<ControllerRumble>();
        playerSound = GetComponent<PlayerSound>();

        this.currentLevel = SceneManager.GetActiveScene().buildIndex;
        ChangeColor(probeColorOff, false, 0);
        LoadGame();
        ResetPlayerState();

        gameOverCanvas = GameObject.FindWithTag("GameOverCanvas");

        UI = GameObject.FindWithTag("UI");

        if (gameOverCanvas == null)
        {
            Canvas[] canvases = UI.GetComponentsInChildren<Canvas>();
            foreach (Canvas canvas in canvases)
            {
                if (canvas.name == "GameOverCanvas")
                {
                    gameOverCanvas = canvas.gameObject;
                    break;
                }
            }
        }

        #if UNITY_EDITOR
            this.ValidateInputs();
        #endif
    }
Example #36
0
 void Start()
 {
     sound = PlayerSound.instance;
     currentHealth = maxHealth;
     healthSlider = GameObject.FindGameObjectWithTag("PlayerHealthUI").GetComponent<Slider>();
 }