Example #1
0
    public void AddTarget( BaseHealth _health )
    {
        #if UNITY_EDITOR
        if ( Network.peerType == NetworkPeerType.Disconnected )
        {
            this.debugTargetMap.Add( this.currentDebugID, _health );
            DebugConsole.Log( "Added target " + this.currentDebugID, _health );
            _health.debugTargetID = this.currentDebugID;
            this.currentDebugID++;
        }
        else
        #endif
        {
            NetworkViewID viewID = _health.GetComponent<NetworkView>().viewID;
            if ( this.targetMap.ContainsKey( viewID ) )
            {
                DebugConsole.Warning( "Target Manager already contains " + viewID
                                     + " (" + this.GetTargetWithID( viewID ).gameObject.name+ ")", _health );
                return;
            }

            DebugConsole.Log( "Adding target " + viewID + " (" + _health.gameObject.name
                             + ") to TargetManager", _health );
            this.targetMap.Add( viewID, _health );
        }

        #if UNITY_EDITOR
        this.debugTargets.Add( _health );
        #endif
    }
Example #2
0
 public void Start()
 {
     m_IslandHealth = gameObject.GetComponent <IslandHealth>();
     m_IslandHealth.TakeDamageEvent += UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.ReduceHealth;
     UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.SetMaxHealth(m_IslandHealth.GetMaxHealth());
     m_IslandHealth.OnResetHealth += UIController.Instance.m_InGameUIController.m_IslandsHealthBarController.ResetHealth;
 }
Example #3
0
    // Use this for initialization
    protected override void Awake()
    {
        ability = AbilityIDList.getAbility(AbilityID.summonSkeleton);
        base.Awake();
        summonWarrior = Ability.getAbility(AbilityID.summonSkeletonWarrior);
        summonMage    = Ability.getAbility(AbilityID.summonSkeletonMage);
        summonArcher  = Ability.getAbility(AbilityID.summonSkeletonArcher);
        summonWarlord = Ability.getAbility(AbilityID.summonSkeletonWarlord);
        summonBrawler = Ability.getAbility(AbilityID.summonSkeletonBrawler);

        skeletonAbilities.Add(ability);
        skeletonAbilities.Add(summonWarrior);
        skeletonAbilities.Add(summonMage);
        skeletonAbilities.Add(summonArcher);
        skeletonAbilities.Add(summonWarlord);
        skeletonAbilities.Add(summonBrawler);

        summonTracker = Comp <SummonTracker> .GetOrAdd(gameObject);

        summonTracker.newSummonEvent += onNewSummon;

        protectionClass = GetComponent <ProtectionClass>();
        if (protectionClass)
        {
            health = protectionClass.healthClass;
        }
        else
        {
            health = GetComponent <BaseHealth>();
        }
        mana = GetComponent <BaseMana>();

        statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject);
    }
    //When the bullet (which was set as Trigger) enters an object with Collider...
    void OnTriggerEnter(Collider other)
    {
        /*
         *      If the collider the bullet enters is an enemy we destroy it and the bullet as well.
         *      Then, we increment the player's score by 10.
         */
        if (other.tag == "Enemy")
        {
            Debug.Log("Enemy");
            Destroy(other.gameObject);
            Destroy(gameObject);
            PlayerScore.playerScore += 10;
        }

        /*
         *      If the collider the bullet enters is a base, then we reduce a point from
         *      the base's "health" and destroy the bullet.
         */
        else if (other.tag == "Base")
        {
            GameObject playerBase = other.gameObject;
            BaseHealth baseHealth = playerBase.GetComponent <BaseHealth> ();
            baseHealth.health -= 1;
            Destroy(gameObject);
        }
    }
    IEnumerator LevelFinished()
    {
        int        levelFinished   = 0;
        BaseHealth bh              = FindObjectOfType <BaseHealth>();
        int        healthDeduction = bh.startHealth - bh.GetHealth();
        int        lastSpawnCount  = 0;

        while (healthDeduction + enemiesKilled != totalEnemiesToSpawn && levelFinished != 6)
        {
            if (lastSpawnCount != healthDeduction + enemiesKilled)
            {
                lastSpawnCount = healthDeduction + enemiesKilled;
                levelFinished  = 0;
            }
            else
            {
                // Level was not ending on a rare occasion
                levelFinished++;
                Debug.Log(levelFinished);
            }
            healthDeduction = bh.startHealth - bh.GetHealth();
            yield return(new WaitForSeconds(1));
        }
        AudioSource.PlayClipAtPoint(victorySfx, Camera.main.transform.position);
        for (int i = 5; i > 0; i--)
        {
            startDelay.text     = "Returning\n to level select \n in " + i + " seconds";
            startDelay.fontSize = 32;
            yield return(new WaitForSeconds(1));
        }
        SceneManager.LoadScene("LevelSelect");
    }
Example #6
0
 public void Start()
 {
     m_PlayersHealth = GetComponent <BaseHealth>();
     m_PlayersHealth.TakeDamageEvent += UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.ReduceHealth;
     UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.SetMaxHealth(m_PlayersHealth.GetMaxHealth());
     m_PlayersHealth.OnResetHealth += UIController.Instance.m_InGameUIController.m_PlayersHealthBarController.ResetHealth;
 }
Example #7
0
 public void onKill(Ability _ability, GameObject target)
 {
     if (snakeOnKillChance > 0 && (_ability == ability))
     {
         float rand = Random.Range(0f, 1f);
         if (rand < snakeOnKillChance)
         {
             if (!usingAbility)
             {
                 usingAbility = GetComponent <UsingAbility>();
             }
             if (usingAbility)
             {
                 usingAbility.UseAbility(AbilityIDList.getAbility(AbilityID.summonSerpent), target.transform.position, false, false);
             }
         }
     }
     if (lifeOnKill != 0 && (_ability == ability))
     {
         float rand = Random.Range(0f, 1f);
         if (rand < lifeOnKill)
         {
             if (!baseHealth)
             {
                 baseHealth = GetComponent <BaseHealth>();
             }
             if (baseHealth)
             {
                 baseHealth.Heal(lifeOnKill);
             }
         }
     }
 }
Example #8
0
 void Awake()
 {
     rb    = GetComponent <Rigidbody2D>();
     col   = transform.Find("Colliders").GetComponent <CircleCollider2D>();
     stats = GetComponent <StatBlock>();
     hp    = GetComponent <BaseHealth>();
 }
Example #9
0
    private void shootLaser()
    {
        laserLine.enabled = true;
        laserAudioSource.Play();

        //Draw the laser
        RaycastHit hit;
        float      distance = 0f;

        if (Physics.Raycast(shootingPoint.position, transform.forward, out hit, 100, wallLayerMask))
        {
            distance = hit.distance;
            Vector3 endPoint = shootingPoint.localPosition + Vector3.forward * distance;
            laserLine.SetPosition(0, shootingPoint.localPosition);
            laserLine.SetPosition(1, endPoint);
        }

        //Get and damage colliders;
        laserTimer -= Time.deltaTime;
        if (laserTimer < 0)
        {
            laserTimer = laserTickRate;
            RaycastHit[] hits;
            hits = Physics.RaycastAll(shootingPoint.position, transform.forward, distance, enemyLayerMask);
            foreach (RaycastHit rayHit in hits)
            {
                BaseHealth health = rayHit.collider.GetComponentInParent <BaseHealth>();
                if (health != null)
                {
                    health.TakeDamage(laserDamage);
                }
            }
        }
    }
Example #10
0
    private void Start()
    {
        resourceController = FindObjectOfType <AMS_ResourceController>();
        if (resourceController == null)
        {
            Debug.Log("can't find resource controller object");
        }

        //this is just to find the bottom of the object
        var capColl = gameObject.GetComponent <CapsuleCollider>();

        if (capColl != null)
        {
            rayOffset = (capColl.height / 2f) * gameObject.transform.localScale.y;
        }
        else
        {
            rayOffset = 1f;
        }

        note = gameObject.GetComponentInChildren <Canvas>().gameObject;
        if (note == null)
        {
            Debug.Log("can't find canvas gameObject");
        }

        baseHealth = FindObjectOfType <BaseHealth>();
        if (baseHealth == null)
        {
            Debug.Log("basehealth not found in scene");
        }
    }
Example #11
0
 // Use this for initialization
 protected override void Awake()
 {
     ability   = AbilityIDList.getAbility(AbilityID.shieldRush);
     health    = GetComponent <BaseHealth>();
     baseStats = GetComponent <BaseStats>();
     base.Awake();
 }
Example #12
0
    // Start is called before the first frame update
    void Start()
    {
        currentbase = FindObjectOfType <BaseHealth>();
        AMS_ScoreController.rankScores      = scoreRanks;
        AMS_ScoreController.score           = 0;
        AMS_ScoreController.scoreMultiplier = 1;
        AMS_ScoreController.parTimes        = parTimes;
        timeOnStart = Time.time;

        baseAlertCurrentTime = 0f;
        alertCurrentTime     = 0f;
        var playerScript = FindObjectOfType <KE_MainPlayer_Script>();

        if (playerScript != null)
        {
            var playerObj = playerScript.gameObject;
            playerHealth = playerObj.GetComponent <AMS_Health_Management>();
            if (playerHealth == null)
            {
                Debug.Log("player health was not where expected");
            }
        }
        else
        {
            Debug.Log("does not seem to be a player in the level");
        }
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        /* swapping if for switch statement, makes code run much faster
         * if(other.tag == "Player")
         * {
         *  Destroy(gameObject);
         *  PlayerScore.playerScore -= (int)EnemyController.Columns * 2;
         * }
         * else if(other.tag == "Base")
         * {
         *  GameObject playerBase = other.gameObject;
         *  BaseHealth baseHealth = playerBase.GetComponent<BaseHealth>();
         *  baseHealth.health -= 1;
         *  Destroy(gameObject);
         * }
         */
        switch (other.tag)
        {
        case "Player":
            Destroy(gameObject);
            PlayerScore.playerScore -= (int)EnemyController.Columns * 2;
            break;

        case "Base":
            GameObject playerBase = other.gameObject;
            BaseHealth baseHealth = playerBase.GetComponent <BaseHealth>();
            baseHealth.health -= 1;
            Destroy(gameObject);
            break;
        }
    }
Example #14
0
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("BaseHealth", true, out subEle);
            subEle.Value = BaseHealth.ToString();

            ele.TryPathTo("Strength", true, out subEle);
            subEle.Value = Strength.ToString();

            ele.TryPathTo("Perception", true, out subEle);
            subEle.Value = Perception.ToString();

            ele.TryPathTo("Endurance", true, out subEle);
            subEle.Value = Endurance.ToString();

            ele.TryPathTo("Charisma", true, out subEle);
            subEle.Value = Charisma.ToString();

            ele.TryPathTo("Intelligence", true, out subEle);
            subEle.Value = Intelligence.ToString();

            ele.TryPathTo("Agility", true, out subEle);
            subEle.Value = Agility.ToString();

            ele.TryPathTo("Luck", true, out subEle);
            subEle.Value = Luck.ToString();
        }
Example #15
0
    private void Start()
    {
        health          = GetComponentInParent <AMS_Health_Management>();
        currentCoolDown = 0f;

        baseHealth = FindObjectOfType <BaseHealth>();
    }
Example #16
0
    // Use this for initialization
    void Start()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius);

        foreach (Collider otherCollider in colliders)
        {
            ExplodingElement explodingElement = otherCollider.gameObject.GetComponent <ExplodingElement>();

            if (explodingElement != null)
            {
                explodingElement.Explode(transform.position, m_ExplosionRadius, m_ExplosionForce);
            }

            BaseHealth <int> health = otherCollider.gameObject.GetComponent <BaseHealth <int> >();
            if (health != null)
            {
                health.Damage(m_Damage);
            }
        }

        m_Camera = Camera.main.GetComponent <CameraController>();
        if (m_Camera != null)
        {
            m_Camera.Shake(m_CameraShake);
        }
    }
Example #17
0
    // Use this for initialization
    protected override void Awake()
    {
        ability = AbilityIDList.getAbility(AbilityID.summonWraith);
        health  = GetComponent <BaseHealth>();
        mana    = GetComponent <BaseMana>();

        if (health)
        {
            statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject);

            tracker = Comp <SummonTracker> .GetOrAdd(gameObject);

            AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject);

            listener.onCritEvent += OnCrit;
        }

        // get wraith prefabs
        if (flameWraithPrefab == null)
        {
            Ability wraithAbility = Ability.getAbility(AbilityID.summonFlameWraith);
            if (wraithAbility && wraithAbility.abilityPrefab)
            {
                SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>();
                if (summon)
                {
                    flameWraithPrefab = summon.entity;
                }
            }

            wraithAbility = Ability.getAbility(AbilityID.summonPutridWraith);
            if (wraithAbility && wraithAbility.abilityPrefab)
            {
                SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>();
                if (summon)
                {
                    putridWraithPrefab = summon.entity;
                }
            }

            wraithAbility = Ability.getAbility(AbilityID.summonBloodWraith);
            if (wraithAbility && wraithAbility.abilityPrefab)
            {
                SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>();
                if (summon)
                {
                    bloodWraithPrefab = summon.entity;
                }
            }
        }

        // spirit escape prefab
        if (spiritEscapePrefab == null)
        {
            spiritEscapePrefab = PrefabList.getPrefab("spiritEscape");
        }

        base.Awake();
    }
Example #18
0
    // Use this for initialization
    void Start()
    {
        baseHealth = FindObjectOfType <BaseHealth>();
        Pathfinder pathfinder = FindObjectOfType <Pathfinder>();
        var        path       = pathfinder.GetPath();

        StartCoroutine(FollowPath(path));
    }
Example #19
0
 // Use to instantiate the class vars and other properties
 private void init()
 {
     // Set vel based on movement type
     rb2 = GetComponent <Rigidbody2D>();
     rb2.gravityScale = 0;
     health           = GetComponent <BaseHealth>();
     explode          = GetComponent <Explode>();
 }
Example #20
0
    public static void MiniBDamage()
    {
        NPC      = new NPCSystem();
        baseHlth = new BaseHealth();
        foreach (var o in NPCSystem.followers)
        {
            if (BB_BasicControls.OutpBuilt != 10)
            {
                if (GameObject.FindGameObjectsWithTag("House").Length > 0)
                {
                    num = (BB_BasicControls.houseBuilt / 2);
                    n   = Mathf.Round(num);

                    if (o.Status == "House")
                    {
                        if (n > 0)
                        {
                            GameObject house = GameObject.FindWithTag("House");
                            Destroy(house);
                            destroyedbuilds++;
                            n--;
                            NPCSystem.removeFollower(o.Id);
                            baseHlth.BaseHealthCalc();
                        }
                    }
                }
                if (GameObject.FindGameObjectsWithTag("Outpost").Length > 0)
                {
                    num1 = (BB_BasicControls.OutpBuilt / 2);
                    n1   = Mathf.Round(num1);
                    if (o.Status == "Outpost")
                    {
                        if (n1 > 0)
                        {
                            GameObject outpost = GameObject.FindWithTag("Outpost");
                            Destroy(outpost);
                            destroyedbuilds++;
                            n1--;
                            NPCSystem.removeFollower(o.Id);
                            baseHlth.BaseHealthCalc();
                        }
                    }
                }
                tags = arr[Random.Range(0, 1)];
                if (o.Status == tags)
                {
                    if (GameObject.FindGameObjectsWithTag(tags).Length > 0)
                    {
                        GameObject building = GameObject.FindWithTag(tags);
                        Destroy(building);
                        destroyedbuilds++;
                        NPCSystem.removeFollower(o.Id);
                        baseHlth.BaseHealthCalc();
                    }
                }
            }
        }
    }
Example #21
0
 void Start()
 {
     body2D     = GetComponent <Rigidbody2D>();
     renderer2D = GetComponent <SpriteRenderer>();
     animator   = GetComponent <Animator>();
     controller = GetComponent <PlayerSubmarineController>();
     health     = GetComponent <BaseHealth>();
     explode    = GetComponent <Explode>();
 }
Example #22
0
    protected virtual void OnTick(BaseHealth target)
    {
        if (Lib.HasTagInHierarchy(target.gameObject, "Player"))
        {
            return;
        }

        target.Damage(1, creator, target.gameObject);
    }
    private void Awake()
    {
        m_ShipHealth = GetComponent <BaseHealth>();

        m_ShipHealth.TakeDamageEvent += m_HealthBarController.ReduceHealth;
        m_ShipHealth.TakeDamageEvent += m_EnemyAnimation.DoOnTakeDamageAnimation;

        m_HealthBarController.SetMaxHealth(m_ShipHealth.GetMaxHealth());
    }
Example #24
0
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag("Player");
     playerHealth = player.GetComponent <PlayerHealth> ();
     baseObject   = GameObject.FindGameObjectWithTag("Base");
     baseHealth   = baseObject.GetComponent <BaseHealth>();
     enemyHealth  = GetComponent <EnemyHealth>();
     anim         = GetComponent <Animator> ();
 }
Example #25
0
    void Awake()
    {
        Laser = LaserPoint.GetComponent <Light>();
        timeBetweenBullets = 1 / MaxFrequence;



        basehealth = GetComponent <BaseHealth>();
    }
    int spawnCheckPositionsMaxTries = 50;                       // Max tries to check for spawn position

    void Start()
    {
        this.GetMinMaxWallsPositions();
        playerHealth = GameObject.Find(GlobalVars.playerTankName).GetComponent <PlayerHealth> ();
        baseHealth   = GameObject.Find(GlobalVars.playerBase).GetComponent <BaseHealth> ();

        // Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time.
        InvokeRepeating("Spawn", spawnTime, spawnTime);
    }
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Base")
     {
         GameObject playerBase = other.gameObject;
         BaseHealth baseHealth = playerBase.GetComponent <BaseHealth>();
         baseHealth.health -= 1;
         Destroy(gameObject);
     }
 }
Example #28
0
    // Use this for initialization
    protected override void Awake()
    {
        ability = AbilityIDList.getAbility(AbilityID.hammerThrow);
        base.Awake();
        mana   = GetComponent <BaseMana>();
        health = GetComponent <BaseHealth>();
        AbilityEventListener ael = AbilityEventListener.GetOrAdd(gameObject);

        ael.onHitEvent += OnHit;
    }
Example #29
0
    // Use this for initialization
    protected override void Awake()
    {
        ability = AbilityIDList.getAbility(AbilityID.volatileReversal);
        AbilityEventListener ael = AbilityEventListener.GetOrAdd(gameObject);

        ael.onKillEvent += OnKill;
        chargeManager    = GetComponent <ChargeManager>();
        health           = GetComponent <BaseHealth>();
        base.Awake();
    }
Example #30
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     playerHealth = player.GetComponent<PlayerHealth>();
     enemyHealth = GetComponent<EnemyHealth>();
     baseObj = GameObject.Find("Base");
     model = baseObj.transform.FindChild("baseModel").FindChild("Mesh1");
     baseHealth = baseObj.GetComponent<BaseHealth>();
     anim = this.GetComponentInChildren<Animator>();
 }
Example #31
0
    void OnTriggerExit2D(Collider2D col)
    {
        BaseHealth i = Lib.FindInHierarchy <BaseHealth>(col.gameObject);

        if (i == null)
        {
            return;
        }
        inside.Remove(i);
    }
Example #32
0
    public void OnTriggerEnter(Collider other)
    {
        BaseHealth health = other.GetComponentInParent <BaseHealth> ();

        if (health != null)
        {
            Debug.Log("Killing " + other.gameObject.name);
            health.KillSelf();
        }
    }
Example #33
0
    public void InitialiseBaseHealth(Team team, ComputerLane computerLane)
    {
        this.team = team;
        GameObject[] bases = GameObject.FindGameObjectsWithTag(gameObject.tag);

        foreach (GameObject other in bases) {
            if(other && other != gameObject) {
                otherBase = other.GetComponent<BaseHealth>();
            }
        }
        this.computerLane = computerLane;
        InitialiseHealth(computerLane);
    }
Example #34
0
 void Start()
 {
     _bd = GetComponent<BaseHealth>();
 }
Example #35
0
    /// <summary>
    /// Called when this bullet hits an object that has a target attached
    /// </summary>
    /// <param name="_target">_target.</param>
    public virtual void OnTargetCollision( BaseHealth _health, bool _passingThrough )
    {
        if ( _health.Owner == null || _health.Owner.team != this.source.health.Owner.team )
        {
            _health.DealDamage( this.desc.damage * this.damageScale, true, this.source.health.Owner );
        }

        if ( !_passingThrough )
        {
            BulletManager.instance.DestroyLocalBullet( this );
        }
    }
Example #36
0
    public bool IsValidTarget( BaseHealth _health, BaseWeaponManager _weaponScript )
    {
        // Ignore dead targets
        if ( _health == null
          || _health.currentHealth <= 0.0f
          || _health.enabled == false
          || _health.gameObject.activeInHierarchy == false
            // The target that is doing the search
          || _health == _weaponScript.health
            // And those that aren't of the type specfied
          || ((int)(_health.targetType) & _weaponScript.restrictions.types) == 0 )
        {
            return false;
        }

        Vector3 vectorToTarget = _health.transform.position - _weaponScript.transform.position;
        if ( _weaponScript.restrictions.ignoreBelowHorizon && Vector3.Dot( vectorToTarget, _weaponScript.transform.up ) < 0.0f )
        {
            return false;
        }

        // Ignore targets out of range
        Vector3 v = _health.transform.position - _weaponScript.restrictions.transform.position;
        float dist = v.magnitude;
        if ( _weaponScript.restrictions.maxDistance > 0.0f && dist > _weaponScript.restrictions.maxDistance )
        {
            return false;
        }

        // Ignore targets not in the team target list
        if ( _health.Owner == null || ((int)_health.Owner.team & _weaponScript.restrictions.teams ) == 0 )
        {
            return false;
        }

        RaycastHit hitInfo;
        bool hit = Physics.Linecast( _weaponScript.transform.position, _health.transform.position,
                                    out hitInfo, this.lineOfSightBlockingLayers );

        if ( hit
          && hitInfo.collider.gameObject != _health.gameObject
          && hitInfo.collider.gameObject != _weaponScript.gameObject )
        {
            return false;
        }

        return true;
    }
Example #37
0
    public bool IsMissileTargetting( BaseHealth _health )
    {
        foreach ( KeyValuePair<NetworkViewID, SmartBullet> pair in this.smartBulletMap )
        {
            SeekingBullet seekingBullet = pair.Value as SeekingBullet;

            if ( seekingBullet == null )
            {
                continue;
            }

            if ( seekingBullet.target == _health )
            {
                return true;
            }
        }

        #if UNITY_EDITOR
        if ( Network.peerType == NetworkPeerType.Disconnected )
        {
            foreach ( KeyValuePair<int, SmartBullet> pair in this.debugSmartBulletMap )
            {
                SeekingBullet seekingBullet = pair.Value as SeekingBullet;
                if ( seekingBullet == null )
                {
                    continue;
                }

                if ( seekingBullet.target == _health )
                {
                    return true;
                }
            }
        }
        #endif
        return false;
    }
Example #38
0
 public void RemoveTarget( BaseHealth _target )
 {
     #if UNITY_EDITOR
     this.debugTargets.Remove( _target );
     if ( Network.peerType == NetworkPeerType.Disconnected )
     {
         this.debugTargetMap.Remove( _target.debugTargetID );
     }
     else
     #endif
     {
         this.targetMap.Remove( _target.GetComponent<NetworkView>().viewID );
     }
 }
Example #39
0
    void Start()
    {
        this.GetMinMaxWallsPositions ();
        playerHealth = GameObject.Find(GlobalVars.playerTankName).GetComponent<PlayerHealth> ();
        baseHealth = GameObject.Find(GlobalVars.playerBase).GetComponent<BaseHealth> ();

        // Call the Spawn function after a delay of the spawnTime and then continue to call after the same amount of time.
        InvokeRepeating ("Spawn", spawnTime, spawnTime);
    }
 void Start()
 {
     playerHealth = GameObject.Find(GlobalVars.playerTankName).GetComponent<PlayerHealth> ();
     baseHealth = GameObject.Find(GlobalVars.playerBase).GetComponent<BaseHealth>();
 }
Example #41
0
    private void AreaOfEffectDamageCheck( BaseHealth _health, 
	      Vector3 _position, float _radius, float _damage, bool _friendlyFire,
	      GamePlayer _sourcePlayer )
    {
        if ( _friendlyFire && _sourcePlayer.team == _health.Owner.team )
        {
            return;
        }

        float distance = (_health.transform.position - _position ).magnitude;
        if ( distance < _radius )
        {
            float multiplier = 1.0f - distance / _radius;
            _health.DealDamage( _damage * multiplier, true, _sourcePlayer );
        }
    }
Example #42
0
    public Rect GetHealthGUIRect( BaseHealth _health )
    {
        Rect r = new Rect();

        if ( _health.guiExtents.Length == 0 )
        {
            Vector3 pos = Camera.main.WorldToScreenPoint( _health.transform.position );
            pos.y = Screen.height - pos.y;
            r.x = pos.x; r.y = pos.y;
            r.height = r.width = this.minimumBracketScale;
        }
        else
        {
            r.xMin = r.yMin = float.MaxValue;
            r.xMax = r.yMax = float.MinValue;

            foreach ( Transform extent in _health.guiExtents )
            {
                Vector2 pos = Camera.main.WorldToScreenPoint( extent.position );
                pos.y = Screen.height - pos.y;

                r.xMin = Mathf.Min( r.xMin, pos.x );
                r.xMax = Mathf.Max( r.xMax, pos.x );

                r.yMin = Mathf.Min( r.yMin, pos.y );
                r.yMax = Mathf.Max( r.yMax, pos.y );
            }

            if ( r.width < this.minimumBracketScale )
            {
                float centre = r.x + r.width/2;
                r.x = centre - this.minimumBracketScale/2;
                r.width = this.minimumBracketScale;
            }

            if ( r.height < this.minimumBracketScale )
            {
                float centre = r.y + r.height/2;
                r.y = centre - this.minimumBracketScale/2;
                r.height = this.minimumBracketScale;
            }
        }
        return r;
    }
Example #43
0
 public void SwitchToNextMissileTargettingMe()
 {
     this.currentTarget = BulletManager.instance.GetNextMissileLock( this, 1 );
 }
Example #44
0
    protected override void Update()
    {
        base.Update();

        if ( this.state != BULLET_STATE.FADING
          && this.health.currentHealth > 0.0f
          && this.distanceTravelled >= this.seekingDesc.seekingDelayDistance
          && this.target != null )
        {
            this.TurnToTarget();
            Vector3 vectorToTarget = (target.transform.position - this.transform.position).normalized;
            float angleToTarget = Vector3.Angle( this.transform.forward, vectorToTarget );
            if ( this.seekingDesc.canAngleOut
              && angleToTarget >= this.seekingDesc.maxDetectionAngle )
            {
                this.target = null;
            }
        }
        this.GetComponent<Rigidbody>().velocity = this.transform.forward * this.seekingDesc.moveSpeed;
    }