Exemple #1
0
        private void AffectObjectsInBeam()
        {
            HashSet <GameObject> objects = beam.ObjectsInBeam;

            foreach (GameObject toAffect in objects)
            {
                HealthTracker health = toAffect.GetComponent <HealthTracker>();
                if (health)
                {
                    health.InflictDamage(agentDamageRate * Time.deltaTime);
                }
                else
                {
                    Grabbable grabbable = toAffect.GetComponent <Grabbable>();
                    if (grabbable != null && grabbable.IsGrabbed)
                    {
                        grabbable.Release();
                    }
                    else if (attract && !repel && Vector3.Distance(toAffect.transform.position, attachmentPoint.transform.position) <= autoGrabRange &&
                             toAffect.GetComponent <MergableObject>().Size <= maxGrabSize)
                    {
                        GrabObject(toAffect);
                    }
                    else
                    {
                        ApplyForceToObject(toAffect);
                    }
                }
            }
        }
Exemple #2
0
    //private Vector3 nextRespawnLocation;


    // Use this for initialization
    void Start()
    {
        rb = GetComponent <Rigidbody2D> ();
        GameObject cameraObject = GameObject.FindGameObjectWithTag("MainCamera");

        myCamera = cameraObject.GetComponent <Camera> ();

        ghost = ghostObject.GetComponent <GhostController> ();

        controllerName = "";
        getControllerName();

        nextShot = 0.0f;

        currentHealth = maxHealth;

        blinkDamageAnimation = GetComponent <BlinkDamageAnimation> ();

        healthTracker = GetComponent <HealthTracker> ();
        healthTracker.startHealth(maxHealth);

        gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController> ();

        isDead = false;
    }
    private void OnTriggerEnter2D(Collider2D collider)
    {
        TeamAssigner         teamAssigner = collider.GetComponent <TeamAssigner>();
        ProjectileController projectile   = collider.GetComponent <ProjectileController>();

        if (projectile != null)
        {
            if (projectile.firingTeam != firingTeam)
            {
                Destroy(projectile.gameObject);
                Destroy(gameObject);
                return;
            }
        }

        if (collider.isTrigger || teamAssigner != null && firingTeam == teamAssigner.team)
        {
            return;
        }
        else
        {
            HealthTracker healthTracker = collider.GetComponent <HealthTracker>();
            if (healthTracker != null)
            {
                healthTracker.TakeDamage(weaponInfo.damage);
            }
            Destroy(gameObject);
        }
    }
 /*Function called from NewSelection and OnEnable, and from the EventManager.cs using the clearSelectionEVT delegate event
  * Nulls all references and disables the panel's game object */
 private void ClearSelection(EVTData data_ = null)
 {
     this.selectedShip  = null;
     this.shipInventory = null;
     this.shipHealth    = null;
     this.panel.SetActive(false);
 }
    /* Function called from the EventManager.cs using the newSelectionEVT delegate event
     * Updates the ship panels on the HUD to show the selected ships' data */
    private void NewSelection(EVTData data_)
    {
        //If the first object in the selection isn't a ship, the selection is cleared and nothing else happens
        if (MouseData.objectSelected[0].GetComponent <Ship>() == null)
        {
            this.ClearSelection();
            return;
        }

        //Makes sure that the number of ships selected matches this component's index
        if (MouseData.objectSelected.Count > this.shipNumber)
        {
            //Sets the references to the selected ship's Ship, Inventory, and Health components
            this.selectedShip  = MouseData.objectSelected[this.shipNumber].GetComponent <Ship>();
            this.shipInventory = MouseData.objectSelected[this.shipNumber].GetComponent <Inventory>();
            this.shipHealth    = MouseData.objectSelected[this.shipNumber].GetComponent <HealthTracker>();

            //Turns on this panel's game object and sets its icon
            this.panel.SetActive(true);

            this.icon.sprite = this.selectedShip.hudIcon;
        }
        //Otherwise, this ship panel is cleared
        else
        {
            ClearSelection();
        }
    }
Exemple #6
0
 private void Awake()
 {
     playerGameObject       = GameObject.FindGameObjectWithTag("Player");
     playerHealthTracker    = playerGameObject.GetComponent <HealthTracker>();
     playerRigidbody2D      = playerGameObject.GetComponent <Rigidbody2D>();
     playerPlayerController = playerGameObject.GetComponent <PlayerController>();
 }
    // Use this for initialization
    void Start()
    {
        // find DICE IN HAND and set the crew

        GameObject           dobject     = transform.Find("DiceInHand").gameObject;
        DiceInHandController dcontroller = dobject.GetComponent <DiceInHandController>();

        dcontroller.Crew = theCrew;

        // health tracker gets a link to crew too
        dobject = transform.Find("HealthTracker").gameObject;
        HealthTracker hcontroller = dobject.GetComponent <HealthTracker> ();

        hcontroller.Crew = theCrew;

        // find the provisions control and set the crew
        dobject = transform.Find("ProvisionsController").gameObject;
        ProvisionsViewController provs = dobject.GetComponent <ProvisionsViewController> ();

        provs.theCrew = theCrew;

        // time tracker
        dobject = transform.Find("TimeDisplay").gameObject;
        TimeDisplayController times = dobject.GetComponent <TimeDisplayController> ();

        times.theCrew = theCrew;
    }
    public void updateHealthTracker()
    {
        GameObject    dobject = transform.Find("HealthTracker").gameObject;
        HealthTracker tracker = dobject.GetComponent <HealthTracker> ();

        tracker.NeedsUpdate = true;
    }
Exemple #9
0
    public void UseWeapon()
    {
        if (currentWeapon == null || isOnCooldown)
        {
            return;
        }

        OnUseWeapon.Invoke();

        CharacterTeamAssigner myTeam = GetComponent <CharacterTeamAssigner>();

        foreach (Collider2D collider in GetCollidersInWeaponRange())
        {
            HealthTracker tracker = collider.GetComponentInParent <HealthTracker>();
            if (tracker != null)
            {
                CharacterTeamAssigner otherTeam = collider.GetComponentInParent <CharacterTeamAssigner>();
                if (otherTeam == null || myTeam == null || myTeam.team != otherTeam.team)
                {
                    tracker.TakeDamage(currentWeapon.damage);

                    Rigidbody2D rb = collider.GetComponentInParent <Rigidbody2D>();
                    if (rb != null)
                    {
                        rb.AddForce((rb.position - (Vector2)transform.position).normalized * currentWeapon.force, ForceMode2D.Impulse);
                    }
                }
            }
        }

        StartCoroutine(WaitForCooldown(currentWeapon.cooldown));
    }
Exemple #10
0
 // Start is called before the first frame update
 void Start()
 {
     playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthTracker>();
     audioSource  = gameObject.GetComponent <AudioSource>();
     rend         = GetComponent <Renderer>();
     itemPickedUp = false;
 }
Exemple #11
0
 void Start()
 {
     playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthTracker>();
     cameraShake  = Camera.main.GetComponent <ScreenEffects>();
     playerSounds = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <PlayerSounds>();
     _anim        = GetComponentInChildren <Animator>();
 }
Exemple #12
0
        static Handler()
        {
            LoadHUD.LoadImages();
            DeathTimers = new Dictionary <string, int>();
            DeathTimers.Clear();

            HealthTracker = Program.MenuIni.AddSubMenu("HealthTracker");

            HealthTracker.AddGroupLabel("HUD");
            HealthTracker.Add("ally", new CheckBox("Draw Ally HUD"));
            HealthTracker.Add("enemy", new CheckBox("Draw Enemy HUD"));
            HealthTracker.Add("RX", new Slider("Right Side X", 170, -200, 200));
            HealthTracker.Add("RY", new Slider("Right Side Y", 10, -200, 200));
            HealthTracker.Add("LX", new Slider("Left Side X", 0, -200, 200));
            HealthTracker.Add("LY", new Slider("Left Side Y", 10, -200, 200));
            HealthTracker.Add("space", new Slider("Spacing Between Huds", 11, 0, 30));

            /*
             * HealthTracker.AddSeparator(0);
             * HealthTracker.AddGroupLabel("Buildings");
             * HealthTracker.Add("World", new ComboBox("World Health Drawings", 1, "Percent", "Current Health"));
             * HealthTracker.Add("Minimap", new ComboBox("MiniMap Health Drawings", 0, "Percent", "Current Health"));
             * HealthTracker.Add("team", new ComboBox("Tracking Team", 0, "Both", "Enemy", "Ally"));
             * HealthTracker.Add("obj_AI_Turret", new CheckBox("Track Turrets Health"));
             * HealthTracker.Add("obj_HQ", new CheckBox("Track Nexues Health"));
             * HealthTracker.Add("obj_BarracksDampener", new CheckBox("Track Inhibitors Health"));
             */
            DeathText = new Text(string.Empty, new Font("Tahoma", 18, FontStyle.Bold))
            {
                Color = System.Drawing.Color.White
            };
            CDText = new Text(string.Empty, new Font("Tahoma", 9, FontStyle.Bold))
            {
                Color = System.Drawing.Color.White
            };
            hudText = new Text(string.Empty, new Font("Tahoma", 14, FontStyle.Bold))
            {
                Color = System.Drawing.Color.White
            };

            foreach (var sprite in sprites)
            {
                sprite.Scale = new Vector2(1, 1);
            }

            Obj_AI_Base.OnPlayAnimation += delegate(Obj_AI_Base sender, GameObjectPlayAnimationEventArgs args)
            {
                var hero = sender as AIHeroClient;
                if (hero == null)
                {
                    return;
                }

                if (args.Animation.ToLower().Contains("death"))
                {
                    DeathTimers.Add(sender.Name, (int)(hero.DeathTimer() + Game.Time));
                }
            };
        }
Exemple #13
0
 // Use this for initialization
 void Start()
 {
     Instance            = this;
     healthImage         = GetComponent <Image> ();
     healthPercantage    = 1f;
     newHealthPercantage = healthPercantage;
     healthImageWidth    = healthImage.rectTransform.rect.width;
 }
Exemple #14
0
 private void Start()
 {
     playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthTracker>();
     _agent       = GetComponent <NavMeshAgent>();
     _animator    = GetComponentInChildren <Animator>();
     _target      = GameObject.FindGameObjectWithTag("Player").transform;
     ghostSounds  = GetComponentInChildren <GhostSounds>();
 }
Exemple #15
0
 // Start is called before the first frame update
 void Start()
 {
     healthTracker       = GameObject.FindGameObjectWithTag("Player").GetComponent <HealthTracker>();
     characterController = GetComponent <CharacterController>();
     _animator           = GetComponentInChildren <Animator>();
     //_cameraAngle = Camera.main.transform.rotation.y * Mathf.Rad2Deg;
     _cameraAngle = -15;
     IsMoveable   = true;
 }
Exemple #16
0
    public override void UpdateLogic(CharacterLogicController controller)
    {
        NavigationTargeter    targeter          = controller.GetComponent <NavigationTargeter>();
        WaypointChainFollower follower          = controller.GetComponent <WaypointChainFollower>();
        HealthTracker         tracker           = controller.GetComponent <HealthTracker>();
        ExcitementTracker     excitementTracker = controller.GetComponent <ExcitementTracker>();
        CharacterTeamAssigner teamAssigner      = controller.GetComponent <CharacterTeamAssigner>();
        WeaponController      weaponController  = controller.GetComponent <WeaponController>();

        bool canAttack  = !weaponController.isOnCooldown;
        bool isPanicked = tracker.currentHealth / tracker.maxHealth <= panicPercentage;

        List <CharacterTeamAssigner> enemiesInVision = new List <CharacterTeamAssigner>();
        List <Potion> potionsInVision = new List <Potion>();

        foreach (Collider2D collider in Physics2D.OverlapCircleAll(controller.transform.position, visionRange))
        {
            CharacterTeamAssigner otherTeamAssigner = collider.GetComponent <CharacterTeamAssigner>();
            Potion potion = collider.GetComponent <Potion>();

            if (otherTeamAssigner != null && otherTeamAssigner.team != teamAssigner.team)
            {
                enemiesInVision.Add(otherTeamAssigner);
            }

            if (potion != null)
            {
                potionsInVision.Add(potion);
            }
        }

        List <CharacterTeamAssigner> enemiesInAttackRange = ClosestUtility.ThresholdList(controller.transform, enemiesInVision, enemyAttackRange);

        bool inCombat = enemiesInAttackRange.Count > 0;

        if (inCombat)
        {
            excitementTracker.GainExcitement(excitementGainedWhenInCombatPerSecond * Time.deltaTime * (isPanicked ? panicExcitementMultiplier : 1.0f));
        }

        if (inCombat && !isPanicked && canAttack)
        {
            targeter.target = ClosestUtility.GetClosestInList(controller.transform, enemiesInAttackRange).transform;
            return;
        }

        bool canGetToPotion = potionsInVision.Count > 0;
        bool wantsPotion    = tracker.currentHealth < tracker.maxHealth;

        if (wantsPotion && canGetToPotion)
        {
            targeter.target = ClosestUtility.GetClosestInList(controller.transform, potionsInVision).transform;
            return;
        }

        targeter.target = follower.currentWaypoint;
    }
Exemple #17
0
 // Update is called once per frame
 void Update()
 {
     if (trackGaios && trackerToDisplay == null)
     {
         trackerToDisplay = PlayerChoices.FindGaiosComponent <HealthTracker>();
     }
     if (trackerToDisplay != null)
     {
         text.text = string.Format("{0}/{1}", trackerToDisplay.currentHealth, trackerToDisplay.maxHealth);
     }
 }
Exemple #18
0
 // Use this for initialization
 private void Start()
 {
     cc       = gameObject.GetComponent <CharacterController>() as CharacterController;
     rb       = gameObject.GetComponent <Rigidbody>() as Rigidbody;
     ht       = gameObject.GetComponent <HealthTracker>() as HealthTracker;
     animator = GetComponent <Animator>();
     // assuming character starts looking to the right:
     lookRight = transform.rotation;
     // calculate rotation flipped 180 degrees:
     lookLeft = lookRight * Quaternion.Euler(0, 180, 0);
 }
 // Update is called once per frame
 void Update()
 {
     if (trackGaios && trackerToDisplay == null)
     {
         trackerToDisplay = PlayerChoices.FindGaiosComponent <HealthTracker>();
     }
     if (trackerToDisplay != null)
     {
         float percentage = trackerToDisplay.currentHealth / trackerToDisplay.maxHealth;
         myRect.anchorMax = new Vector2(percentage, myRect.anchorMax.y);
     }
 }
Exemple #20
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        TeamAssigner otherTeamAssigner = collision.collider.GetComponent <TeamAssigner>();

        if (otherTeamAssigner != null && otherTeamAssigner.team != assigner.team)
        {
            HealthTracker healthTracker = collision.collider.GetComponent <HealthTracker>();
            if (healthTracker != null)
            {
                healthTracker.TakeDamage(damage);
            }
        }
    }
Exemple #21
0
    // Start is called before the first frame update
    void Start()
    {
        _animator      = GetComponentInChildren <Animator>();
        _playerTracker = GetComponent <PlayerTracker>();
        var player = GameObject.FindGameObjectWithTag("Player");

        _playerTransform = player.transform;
        _playerCollider  = player.GetComponent <Collider>();
        _playerHealth    = player.GetComponent <HealthTracker>();
        _meleeCollider   = transform.Find("Melee Collider")
                           .GetComponent <Collider>();
        Debug.Log(_meleeCollider);
        _isAttacking = false;
    }
Exemple #22
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log(other.tag);
        if (other.tag == "Enemy")
        {
            enemyObject = other.GetComponent <HealthTracker>();
            enemyObject.ReduceHealth(_damage);
        }

        if (other.tag == "Amulet")
        {
            Debug.Log("Found amulet");
            //amulet = other.GetComponent<AmuletBoss>();
            //amulet.TakeDamage(_damage);
        }
    }
Exemple #23
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
#if UNITY_EDITOR
        if (!EditorApplication.isPlaying)
        {
            return;
        }
#endif
        CharacterTeamAssigner teamAssigner = collision.GetComponent <CharacterTeamAssigner>();
        if (teamAssigner != null && teamAssigner.team == potionSettings.teamToHeal)
        {
            HealthTracker tracker = collision.GetComponent <HealthTracker>();
            tracker.RestoreHealth(potionSettings.healAmount);
        }
        gameObject.SetActive(false);
    }
Exemple #24
0
    public bool AreEnemiesInRange()
    {
        CharacterTeamAssigner myTeam = GetComponent <CharacterTeamAssigner>();

        foreach (Collider2D collider in GetCollidersInWeaponRange())
        {
            HealthTracker tracker = collider.GetComponentInParent <HealthTracker>();
            if (tracker != null)
            {
                CharacterTeamAssigner otherTeam = collider.GetComponentInParent <CharacterTeamAssigner>();
                if (otherTeam == null || myTeam == null || myTeam.team != otherTeam.team)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
        static void Main(string[] args)
        {
            // Create health tracker.
            HealthTracker tracker = new HealthTracker();

            Greeting();
            Console.WriteLine("\nUser input: ");

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                switch (key.KeyChar)
                {
                case 'h':
                case 'H':
                    tracker.Stop();
                    Greeting();
                    break;

                case 'r':
                case 'R':
                    tracker.Reset();
                    break;

                case 'q':
                case 'Q':
                    tracker.Quit();
                    break;

                default:
                    tracker.RunOrStop();
                    Console.Write("\nUser input: ");
                    break;
                }
            }
        }
Exemple #26
0
    public void RevertToPlacement()
    {
        HealthTracker tracker = GetComponent <HealthTracker>();

        tracker.FullRestore();
    }
Exemple #27
0
 public void SetTrackerFromObject(Transform t)
 {
     tracker = t.GetComponentInChildren <HealthTracker>();
 }
 // Start is called before the first frame update
 void Start()
 {
     aiMovement = GetComponentInParent <AIMovement>();
     health     = GetComponentInParent <HealthTracker>();
     anim       = GetComponent <Animator>();
 }
 // Start is called before the first frame update
 void Start()
 {
     anim           = GetComponent <Animator>();
     playerMovement = GetComponentInParent <PlayerMovement>();
     playerHealth   = GetComponentInParent <HealthTracker>();
 }
 private void Start()
 {
     ht = FindObjectOfType <HealthTracker>() as HealthTracker;
 }