예제 #1
0
    void Start()
    {
        go = gameObject;

        if (go != null)
        {
            if (go.GetComponent <PlayerController>()) //<<------ if this object is the player
            {
                pHealthSystem = go.GetComponent <PlayerHealthSystem>();
            }
            else if (go.GetComponent <EnemyHandleInteract>()) //<<------------ if this object is an enemy
            {
                eHandleInteract = go.GetComponent <EnemyHandleInteract>();
            }
            else if (go.GetComponent <BreakableObject>()) //<<------- if this object is a breakable object
            {
                bO = go.GetComponent <BreakableObject>();
            }
            else if (go.GetComponent <RollingObject>()) //<<--------- if this object is a rolling object
            {
                rO = go.GetComponent <RollingObject>();
            }
        }
        else
        {
            Debug.LogError("No game object assigned to slot!");
        }
    }
예제 #2
0
 public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     if (GameObject.FindGameObjectsWithTag("Player") != null)
     {
         plhp = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();
     }
 }
예제 #3
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        GameObject objectHit = col.gameObject;

        if (objectHit != null)
        {
            RecieveDamage objectRecieveDamage = objectHit.GetComponent <RecieveDamage>();

            if (objectRecieveDamage != null)
            {
                print("City killed " + objectHit.name);

                PlayerHealthSystem pHeathSyst = objectHit.gameObject.GetComponent <PlayerHealthSystem>();

                if (pHeathSyst != null && !pHeathSyst.isDead)
                {
                    pHeathSyst.KillPlayer();
                }
                else
                {
                    objectRecieveDamage.GetHit(Vector2.left, 100f, 0, 0, 0);
                }

                PlayVariedOneShot(crushSound, crushVolume, false);
            }
            else
            {
                print("City ran over " + objectHit.name);
                SmashingWallEffect(objectHit.transform.position);
                PlayVariedOneShot(smashSound, smashVolume, true);
            }
        }
    }
예제 #4
0
 void Start()
 {
     hurtSound           = gameObject.GetComponent <AudioSource>();
     characterController = gameObject.GetComponent <CharacterController>();
     playerHealthSystem  = gameObject.AddComponent <PlayerHealthSystem>();
     playerHealthSystem.Initialize(100, 100);
 }
예제 #5
0
    protected override void applyEffect()
    {
        PlayerHealthSystem health = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();

        health.SetHealth(health.GetHealth() + 1f);
        sHealthGui.Access().SetHealthPlayer(health.GetHealth() + 1f, health.GetHealth());
    }
 private void OnValidate()
 {
     _pathProcessor = waypoints.GetComponent <PathProcessor>();
     _towerManager  = towers.GetComponent <TowerManager>();
     _camera        = camera.GetComponent <Camera>();
     _healthSystem  = GetComponent <PlayerHealthSystem>();
     Instance       = this;
 }
예제 #7
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         m_playerHealth = collision.GetComponent <PlayerHealthSystem>();
         m_playerHealth.CurrentCheckpoint = this;
     }
 }
예제 #8
0
 private void Awake()
 {
     stats = GetComponent <CharacterStats>();
     playerHealthSystem = GetComponent <PlayerHealthSystem>();
     playerController   = GetComponent <PlayerController>();
     abilityController  = GetComponent <AbilityController>();
     playerRigidbody2D  = GetComponent <Rigidbody2D>();
 }
예제 #9
0
    /// <summary>
    /// Used to Initialize any necessary component variables (e.g. Rigidbody2D, BoxCollider2D, etc.)
    /// </summary>
    private void InitializePlayerComponents()
    {
        // Initialize Player Systems (e.g. health, attack, etc.)
        m_playerHealthSystem = GetComponent <PlayerHealthSystem>();

        m_playerRigidbody = GetComponent <Rigidbody2D>();
        m_groundCheck     = GetComponentInChildren <GroundCheck>();
        m_PlayerAnim      = GetComponent <Animator>();
    }
예제 #10
0
 private void Awake()
 {
     // Gather required component references and values
     m_groundCheck           = GetComponentInChildren <GroundCheck>();
     m_primaryPlayerCollider = GetComponent <BoxCollider2D>();
     m_playerRigidbody       = GetComponent <Rigidbody2D>();
     m_playerMovementHandler = GetComponent <PlayerMovementHandler>();
     m_playerHealthSystem    = GetComponent <PlayerHealthSystem>();
 }
예제 #11
0
 private void Awake()
 {
     if (player == null)
     {
         player = GameObject.FindObjectOfType <PlayerHealthSystem>();
     }
     SceneManager.sceneUnloaded += DereferencePlayerHealth;
     UpdateHealthText(player.GetCurrentHP());
     player.OnPlayerHealthUpdate += UpdateHealthText;
 }
 private void MakeThisObjectSingleton()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
예제 #13
0
    protected override void Start()
    {
        base.Start();

        pFeedback = GetComponent <PlayerFeedback>();
        pAudio    = GetComponent <PlayerAudioController>();
        pHealth   = GetComponent <PlayerHealthSystem>();

        groundLayerMask = ((1 << groundLayer)) | ((1 << breakableFloorsLayer)) | ((1 << slidingSurfaceLayer)) | ((1 << breakableObjectsLayer)) | ((1 << rollingObjectsLayer));
        wallLayerMask   = ((1 << groundLayer)) | ((1 << breakableFloorsLayer)) | ((1 << breakableObjectsLayer));
    }
예제 #14
0
    void TriggerAttack()
    {
        Collider2D PlayerToAttack = Physics2D.OverlapCircle(myrb.position, 5f, PlayerLayer);

        if (PlayerToAttack != null)
        {
            PlayerHealthSystem playerHealthSystem = PlayerToAttack.GetComponent <PlayerHealthSystem>();
            Debug.Log("Attack");
            PlayerHealthSystem PlayerHealth = PlayerToAttack.GetComponent <PlayerHealthSystem>();
            PlayerHealth.TakeDamage(HitPoints);
        }
    }
예제 #15
0
    void Awake()
    {
        objectiveHealth = GetComponent <ObjectiveHealthSystem>();
        playerHealth    = GetComponent <PlayerHealthSystem>();
        stateSystem     = GetComponent <StateSystem>();
        waveSystem      = GetComponent <WaveSystem>();

        playerAction = player1.GetComponent <PlayerActionSystem>();

        enemies    = new List <GameObject>();
        deadBodies = new List <GameObject>();
    }
예제 #16
0
    /// <summary>
    /// Used to Initialize any necessary component variables (e.g. Rigidbody2D, BoxCollider2D, etc.)
    /// </summary>
    private void InitializePlayerComponents()
    {
        // Initialize Player Systems (e.g. health, jump, attack, etc.)
        m_playerHealthSystem = GetComponent <PlayerHealthSystem>();
        // Jump component is needed in order to properly clamp the player's max velocity on the x & y axis
        m_playerJumpHandler = GetComponent <PlayerJumpHandler>();
        m_shoveHandler      = GetComponent <PlayerShoveHandler>();

        m_playerRigidbody      = GetComponent <Rigidbody2D>();
        m_playerSpriteRenderer = GetComponent <SpriteRenderer>();
        m_groundCheck          = GetComponentInChildren <GroundCheck>();
        m_playerAnim           = GetComponent <Animator>();
    }
예제 #17
0
    protected virtual void OnTriggerEnter2D(Collider2D collision)
    {
        pHealthSyst = collision.gameObject.GetComponent <PlayerHealthSystem>();

        if (pHealthSyst != null && pHealthSyst.spawnZone != this)
        {
            pHealthSyst.spawnZone = this;
            Toolbox.GetInstance().GetAudioManager().PlayConsistentOneShot(respawnSound, respawnVolume);

            disposablePartSyst = Instantiate(Resources.Load("RespawnParticleSystem", typeof(GameObject))) as GameObject;
            disposablePartSyst.transform.position = gameObject.transform.position;
            Destroy(disposablePartSyst, 2f);
        }
    }
예제 #18
0
 private void OnTriggerEnter(Collider col)
 {
     switch (col.gameObject.tag)
     {
     case "Player":
         PlayerHealthSystem playerHealth = col.gameObject.GetComponent <PlayerHealthSystem>();
         if (!playerHealth.IsHealthFull())
         {
             playerHealth.ChangeHealth(1);
             soundController.PlayHPPickUpSound();
             Destroy(this.gameObject);
         }
         break;
     }
 }
예제 #19
0
    void Start()
    {
        playerHealthSystem = gameObject.GetComponentInParent <PlayerHealthSystem>();
        playerHealthSystem.invulnerable = true;
        shieldAudioSource = GetComponent <AudioSource>();
        shieldSounds      = new AudioClip[]
        {
            (AudioClip)Resources.Load("Sounds/SuperShieldActiveV3"),
            (AudioClip)Resources.Load("Sounds/SuperShieldDeactivate"),
            (AudioClip)Resources.Load("Sounds/SuperShieldImpact")
        };

        dealDamage = false;
        StartCoroutine(ShieldActive());
    }
    //Just checks if a collider overlaps with a trigger. The thing that is in you. Overlap.
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Boundary") || other.CompareTag("LightEnemy") || other.CompareTag("MediumEnemy") || other.CompareTag("HeavyEnemy") || other.CompareTag("OverEnemy") || other.CompareTag("EnemyBullet"))
        {
            return;
        }

        health = other.GetComponent <PlayerHealthSystem>();

        if (health == null)
        {
            return;
        }

        health.Damage(damageAmmount);
    }
예제 #21
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Boundary") || other.CompareTag("LightEnemy") || other.CompareTag("MediumEnemy") || other.CompareTag("HeavyEnemy") || other.CompareTag("OverEnemy") || other.CompareTag("EnemyBullet"))
        {
            return;
        }

        health = other.GetComponent <PlayerHealthSystem>();

        if (health == null)
        {
            return;
        }
        dealDamage = true;
        StartCoroutine(BeamDamage());
    }
예제 #22
0
    private void Start()
    {
        playerHP = GameObject.Find("Player").GetComponent <PlayerHealthSystem>();
        exitDoor = GameObject.Find("Exit Door Collider").GetComponent <ExitDoorCollider>();

        gameOverUI      = GameObject.Find("Game End Screen").GetComponent <IUIGenericElement>();
        scoreSystemUI   = GameObject.Find("Score Manager").GetComponent <IUIGenericElement>();
        waveIndicatorUI = GameObject.Find("Wave Indicator UI").GetComponent <IUIGenericElement>();

        gameWinUI        = GameObject.Find("Game Win Screen").GetComponent <IUIGenericElement>();
        playerWeaponUI   = GameObject.Find("Weapon Player UI").GetComponent <IUIGenericElement>();
        playerJoystickUI = GameObject.Find("Virtual Joystick Handler").GetComponent <IUIGenericElement>();

        currentSceneName = SceneManager.GetActiveScene().name;

        Application.targetFrameRate = 60;
    }
예제 #23
0
    private void OnTriggerEnter(Collider other)
    {
        //Does nothing to boundary or player tags.
        if (other.CompareTag("Boundary") || other.CompareTag("Enemy") || other.CompareTag("EnemyBullet"))
        {
            return;
        }

        //Grabs a refference to the other object's health system
        health = other.GetComponent <PlayerHealthSystem>();
        if (health == null)
        {
            return;
        }

        //Tells that health system to deal X damage.
        health.Damage(damageAmmount);
    }
예제 #24
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Boundary") || other.CompareTag("LightEnemy") || other.CompareTag("MediumEnemy") || other.CompareTag("HeavyEnemy") || other.CompareTag("OverEnemy") || other.CompareTag("EnemyBullet"))
        {
            return;
        }

        health = other.GetComponent <PlayerHealthSystem>();

        if (health == null)
        {
            return;
        }

        health.Damage(damageAmmount);
        Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation);
        Destroy(gameObject);
    }
예제 #25
0
    //Just checks if a collider overlaps with a trigger. The thing that is in you. Overlap.
    private void OnTriggerEnter(Collider other)
    {
        bool whoDunIt;

        if (other.CompareTag("Boundary") || other.CompareTag("Enemy"))
        {
            return;
        }

        whatPlayer = other.GetComponent <PlayerController>();
        health     = other.GetComponent <PlayerHealthSystem>();

        if (health == null)
        {
            return;
        }

        whoDunIt = whatPlayer.whichPlayer;
        addScore.AddPoints(whoDunIt);
        health.ExtraLife();
        Instantiate(pickUpSoundPlayer, gameObject.transform.position, gameObject.transform.rotation);

        Destroy(gameObject);
    }
예제 #26
0
 // Start is called before the first frame update
 new protected void Start()
 {
     base.Start();
     playerHealthSystem = GameController.Player.GetComponentInChildren <PlayerHealthSystem>();
 }
예제 #27
0
 void Start()
 {
     plhp = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();
 }
예제 #28
0
 private void Awake()
 {
     instance      = this;
     _healthSystem = new PlayerHealthSystem(_health, _healthText);
 }
예제 #29
0
    protected override bool canBeCollected()
    {
        PlayerHealthSystem health = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();

        return(health.GetHealth() < health.GetMaxHealth());
    }
예제 #30
0
 // Use this for initialization
 void Start()
 {
     phs       = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();
     image     = this.GetComponent <Image>();
     imageFill = phs.Health;
 }