Ejemplo n.º 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!");
        }
    }
Ejemplo n.º 2
0
 public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     if (GameObject.FindGameObjectsWithTag("Player") != null)
     {
         plhp = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();
     }
 }
Ejemplo n.º 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);
            }
        }
    }
Ejemplo n.º 4
0
 void Start()
 {
     hurtSound           = gameObject.GetComponent <AudioSource>();
     characterController = gameObject.GetComponent <CharacterController>();
     playerHealthSystem  = gameObject.AddComponent <PlayerHealthSystem>();
     playerHealthSystem.Initialize(100, 100);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 7
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         m_playerHealth = collision.GetComponent <PlayerHealthSystem>();
         m_playerHealth.CurrentCheckpoint = this;
     }
 }
Ejemplo n.º 8
0
 private void Awake()
 {
     stats = GetComponent <CharacterStats>();
     playerHealthSystem = GetComponent <PlayerHealthSystem>();
     playerController   = GetComponent <PlayerController>();
     abilityController  = GetComponent <AbilityController>();
     playerRigidbody2D  = GetComponent <Rigidbody2D>();
 }
Ejemplo n.º 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>();
    }
Ejemplo n.º 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>();
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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));
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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>();
    }
Ejemplo n.º 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>();
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 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());
    }
Ejemplo n.º 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;
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 26
0
 // Start is called before the first frame update
 new protected void Start()
 {
     base.Start();
     playerHealthSystem = GameController.Player.GetComponentInChildren <PlayerHealthSystem>();
 }
Ejemplo n.º 27
0
 void Start()
 {
     plhp = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();
 }
Ejemplo n.º 28
0
 private void Awake()
 {
     instance      = this;
     _healthSystem = new PlayerHealthSystem(_health, _healthText);
 }
Ejemplo n.º 29
0
    protected override bool canBeCollected()
    {
        PlayerHealthSystem health = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealthSystem>();

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