Exemple #1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }

        /* If the other object has the same tag, ignore the collision.
         * This prevents enemies from colliding with hazards, as well as stops shots from colliding with the shooter.
         */
        if (other.tag == gameObject.tag)
        {
            return;
        }

        ActorHealth otherHealth = other.GetComponent <ActorHealth>();

        if (otherHealth != null)
        {
            otherHealth.TakeDamage(damage);
        }

        /*
         * else
         * {
         *  Destroy(other.gameObject);
         * }
         */
    }
    private void Awake()
    {
        Mobile = GetRequiredComponent <Mobile>();

        Health           = GetRequiredComponent <ActorHealth>();
        Health.HitEvent += HitHandler;
    }
 private void OnActorDamaged(ActorHealth actor)
 {
     if (_flashDamageCoroutine == null)
     {
         _flashDamageCoroutine = StartCoroutine(FlashDamage(actor.DamageInvulnerabilityDuration));
     }
 }
Exemple #4
0
    public void ApplyDamage(ActorHealth actor)
    {
        int damage = Random.Range(DamageMin, DamageMax);

        actor.TakeDamage(damage, this.gameObject.transform.position, HitKnockback);
        Destroy(this.gameObject);
    }
Exemple #5
0
 private void Start()
 {
     if (TargetHealth == null)
     {
         TargetHealth = GameObject.FindGameObjectWithTag(Tags.Player).GetComponent <ActorHealth>();
     }
 }
    private void SetupOnStart()
    {
        string[] objNameTable = new string[GameManager.MAX_ACTOR_COUNT]
        {
            "HealthUI_1",
            "HealthUI_2",
            "HealthUI_3",
        };

        for (int i = 0; i < healthUIs.Length; ++i)
        {
            // AddComponentだけでは階層構造を維持するのに手間がかかるので、
            // prefabを利用するのがベターかも。
            ActorHealthUI clone = Instantiate(prefabHealthUI);
            clone.gameObject.SetActive(true);
            healthUIs[i] = clone;

            // 初期化
            GameManager gm    = GameManager.Instance;
            Actor       actor = gm.actors[i];
            healthUIs[i].transform.SetParent(actor.transform, false);

            ActorHealth health = actor.actorModel.health;
            healthUIs[i].Initialize(health);

            // 名前
            clone.name = objNameTable[i];
        }
    }
Exemple #7
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Boundary")
        {
            return;
        }


        /* If the other object has the same tag, ignore the collision.
         * This prevents shots from colliding with the shooter.
         */
        if (other.tag == gameObject.tag)
        {
            return;
        }

        ActorHealth ph = other.GetComponent <ActorHealth>();

        if (ph != null)
        {
            ph.TakeDamage(damage);

            Destroy(gameObject);
            if (explosion != null)
            {
                Instantiate(explosion, transform.position, transform.rotation);
            }
        }
    }
 void Start()
 {
     actorHealth = GetComponent <ActorHealth>();
     actorHealth.setActive(false);
     slice    = GetComponent <Slice>();
     fireRain = GetComponent <FireRain>();
 }
Exemple #9
0
        private void Unregister(ActorHealth enemy)
        {
            Enemies.Remove(enemy as EnemyHealth);

            PositionTracker.Unsubscribe(enemy, OnEnemyPositionUpdate);

            enemy.OnActorDeath -= Unregister;
        }
 // Use this for initialization
 void Start()
 {
     saveable    = GetComponent <Saveable>();
     enemyHealth = GetComponent <ActorHealth>();
     if (enemyHealth == null)
     {
         enemyHealth = GetComponentInChildren <ActorHealth>();
     }
 }
    private void OnHitEvent(ActorHealth actor, GameObject source)
    {
        var handler = HitEvent;

        if (handler != null)
        {
            handler(actor, source);
        }
    }
    protected override void grantBonus()
    {
        GameSession  gameSession  = FindObjectOfType <GameSession>();
        EnemySpawner enemySpawner = FindObjectOfType <EnemySpawner>();
        ActorHealth  playerHealth = FindObjectOfType <Player>().GetComponent <ActorHealth>();

        gameSession.setStartWaveIndex(enemySpawner.getCurrentWave());
        gameSession.setPlayerExtraHealth(playerHealth.getMaxHealthExtra());
        gameSession.saveScore();
    }
Exemple #13
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        ActorHealth health = collider.GetComponent <ActorHealth>();

        if (active && health != null && health.canBeHit())
        {
            health.hit(this);
            notify();
        }
    }
 private void HitHandler(ActorHealth health, GameObject source)
 {
     _hurtPending   = true;
     _hurtDirection = -Mathf.Sign(source.transform.position.x - Mobile.transform.position.x);
     if (_nextHurtIsCritical)
     {
         _nextHurtIsCritical  = false;
         _criticalHurtPending = true;
     }
 }
Exemple #15
0
    private void OnTargetHit(ActorHealth actor, GameObject source)
    {
        var container = transform;
        var total     = actor.TotalHitCount;
        var current   = actor.CurrentHitCount;

        for (var i = 0; i < total; i++)
        {
            container.GetChild(i).Find("Fill").GetComponent <Image>().enabled = i < current;
        }
    }
Exemple #16
0
    // Start is called before the first frame update
    void Start()
    {
        gun        = this.gameObject.GetComponent <Gun>();
        controller = this.gameObject.GetComponent <BasicPlayerController>();
        health     = this.gameObject.GetComponent <ActorHealth>();

        damageText.text    = "Damage: " + gun.damage;
        firedelayText.text = "Fire Delay: " + gun.shotCooldown;
        speedText.text     = "Speed: " + controller.movementSpeed;
        healthText.text    = "Health: " + health.currentHealth;
    }
Exemple #17
0
    private void Awake()
    {
        delayForPowerUp = new WaitForSeconds(powerUpDelay);
        stationHealth   = GetComponent <ActorHealth>();

        foreach (TurretAttachPoint t in turretAttachPoints)
        {
            t.connectedStation = this;
        }

        AddButton();
    }
Exemple #18
0
    // Start is called before the first frame update
    void Start()
    {
        player = GameObject.Find("Player");
        rb     = GetComponent <Rigidbody2D>();
        bc     = GetComponent <BoxCollider2D>();
        health = GetComponent <ActorHealth>();
        //bc.enabled = true;
        lastX = transform.position.x;
        lastY = transform.position.y;

        state = State.Walk;
    }
    private void Start()
    {
        var beatManager = BeatManager.Instance;

        if (beatManager == null)
        {
            enabled = false;
            return;
        }

        BeatManager.Instance.BeatEvent += OnBeatEvent;
        _health = GetComponent <ActorHealth>();
    }
    public void Initialize(ActorHealth actorHealth)
    {
        targetActorHealth = actorHealth;
        if (targetActorHealth != null)
        {
            // コールバック登録
            targetActorHealth.ChangeNowHealthEventHandler += updateNowHealth;
            targetActorHealth.ChangeMaxHealthEventHandler += updateMaxHealth;

            // 初期値設定
            nowHealthValue = targetActorHealth.NowHealth;
            maxHealthValue = targetActorHealth.MaxHealth;
        }

        updateHealthText();
    }
Exemple #21
0
        /// <summary>
        /// Updates the health.
        /// </summary>
        /// <param name="healthComponent">The health component.</param>
        private void UpdateHealth(ActorHealth healthComponent)
        {
            var percentage = healthComponent.Percentage;

            if (percentage > this.redHealthImage.fillAmount)
            {
                this.healthImage.fillAmount    = percentage;
                this.redHealthImage.fillAmount = percentage;
                updateHealth = false;
            }
            else
            {
                this.healthImage.fillAmount = percentage;
                this.redHealthHoldDelay     = this.redHealthHoldTime;
                this.redHealthFadeDelay     = 0;
                updateHealth = true;
            }
        }
Exemple #22
0
    //ActorHealth ownerHealth;
    // Start is called before the first frame update
    void Start()
    {
        /*if(owner == null){
         *  owner = this.gameObject.transform.parent.gameObject;
         *
         *  if(owner == null){Debug.LogError("Weakpoint created without owner!");}
         * }
         * ownerHealth = owner.GetComponent<ActorHealth>();
         * if(ownerHealth == null){Debug.LogError("Weakpoint owner can't take damage!");}*/

        if (ownerHealth == null)
        {
            ownerHealth = this.gameObject.transform.parent.gameObject.GetComponent <ActorHealth>();
            if (ownerHealth == null)
            {
                Debug.LogError("Weakpoint owner can't take damage!");
            }
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log(other);
        if (other.CompareTag("SceneChange"))
        {
            Debug.Log("Scene Changed to BossScene");
            SceneManager.LoadScene(sceneToLoad);
        }
        if (other.CompareTag("Gluttony"))
        {
            //Debug.Log("Collided");
            PlayerMovement playerMov    = player.GetComponent <PlayerMovement>();
            ActorHealth    playerHealth = player.GetComponent <ActorHealth>();
            TestBoss       gluttonyMov  = gluttony.GetComponent <TestBoss>();
            playerMov.velocity += Vector2.Scale(gluttonyMov.movementDirection, 10.0f *
                                                new Vector2((Mathf.Log(1f / (Time.deltaTime * playerMov.Drag.x + 1)) / -Time.deltaTime), (Mathf.Log(1f / (Time.deltaTime * playerMov.Drag.y + 1)) / -Time.deltaTime)));

            if (gluttonyMov.state == TestBoss.State.Walk)
            {
                // reduces player health by 1 when gluttony is walking
                playerHealth.takeDamage(1);
            }
            else if (gluttonyMov.state == TestBoss.State.Crushed)
            {
                // reduces player health by 5 when gluttony is slamming/crushing
                playerHealth.takeDamage(3);
            }
        }
        if (other.CompareTag("Gluttony Projectile"))
        {
            ActorHealth playerHealth = player.GetComponent <ActorHealth>();
            playerHealth.takeDamage(3);
        }
        if (other.CompareTag("Gluttony Bite"))
        {
            ActorHealth playerHealth = player.GetComponent <ActorHealth>();
            playerHealth.takeDamage(1);
        }
    }
    IEnumerator FireLaser()
    {
        float dur = duration;

        line.enabled = true;
        while (dur > 0)
        {
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;
            line.SetPosition(0, ray.origin);
            if (Physics.Raycast(ray, out hit, 20))
            {
                line.SetPosition(1, hit.point);

                Collider    other = hit.collider;
                ActorHealth ph    = other.GetComponent <ActorHealth>();
                if (ph != null)
                {
                    if (other.tag != this.tag)
                    {
                        ph.TakeDamage(dps * Time.deltaTime);
                    }

                    if (explosion != null)
                    {
                        Instantiate(explosion, hit.point, other.transform.rotation);
                    }
                }
            }
            else
            {
                line.SetPosition(1, ray.GetPoint(20));
            }
            dur -= Time.deltaTime;

            yield return(null);
        }
        line.enabled = false;
    }
Exemple #25
0
    private void Start()
    {
        _hitPointPrefab = transform.GetChild(0).gameObject;
        _hitPointPrefab.transform.SetParent(null);

        if (Target == null)
        {
            var targetObject = GameObject.FindGameObjectWithTag(TargetTag);
            if (targetObject != null)
            {
                Target = targetObject.GetComponent <ActorHealth>();
            }
        }

        if (Target == null)
        {
            enabled = false;
            return;
        }

        InitializeHitPoints();
        Target.HitEvent += OnTargetHit;
    }
 // Use this for initialization
 void Start()
 {
     playerHealth = GetComponent <ActorHealth>();
 }
Exemple #27
0
 private void OnPlayerDeath(ActorHealth playerData)
 {
     playerData.OnActorDeath -= OnPlayerDeath;
     Destroy(_feet);
     Destroy(this);
 }
Exemple #28
0
 // Use this for initialization
 void Start()
 {
     playerHealth = GetComponent <ActorHealth>();
     sceneLoader  = FindObjectOfType <SceneLoader>();
 }
Exemple #29
0
 private void Start()
 {
     _health = GetComponentInParent <ActorHealth>();
 }
 // Start is called before the first frame update
 void Start()
 {
     health = this.gameObject.GetComponent <ActorHealth>();
 }