Esempio n. 1
0
    public void UpdateTargetHealth(int oldHealth, int newHealth)
    {
        HeroCombat targetCombat = heroCombat.target.heroCombat;

        targetHealth.fillAmount = (float)targetCombat.health / (float)targetCombat.maxHealth;
        targetHealthText.text   = "Health: " + targetCombat.health + " / " + targetCombat.maxHealth;
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     heroAvatar          = GetComponent <HeroAvatar> ();
     heroMovement        = GetComponent <HeroMovement> ();
     heroCombat          = GetComponent <HeroCombat> ();
     heroHud             = GetComponent <HeroHud> ();
     characterController = GetComponent <CharacterController> ();
     camera = GetComponentInChildren <Camera>(true);
     camera.gameObject.tag = "LocalHeroCamera";
 }
Esempio n. 3
0
    public void UpdateTarget(HeroManager oldTarget, HeroManager newTarget)
    {
        HeroManager target       = heroCombat.target;
        HeroCombat  targetCombat = target.heroCombat;

        targetStatusBar.SetActive(true);
        targetName.text               = target.netId.ToString();
        targetHealth.fillAmount       = (float)targetCombat.health / (float)targetCombat.maxHealth;
        targetHealthText.text         = "Health: " + targetCombat.health + " / " + targetCombat.maxHealth;
        targetCombat.OnHealthChanged += UpdateTargetHealth;
        if (oldTarget != null)
        {
            oldTarget.heroCombat.OnHealthChanged -= UpdateTargetHealth;
        }
    }
Esempio n. 4
0
    void Start()
    {
        hero       = GetComponent <HeroManager>();
        heroCombat = hero.heroCombat;
        Transform heroHudTransform = transform.FindChild("HeroHud");

        if (!isLocalPlayer)
        {
            return;
        }

        // activate self, only on local hero's screen
        heroHudTransform.gameObject.SetActive(true);
        heroHudTransform.FindChild("EventSystem").gameObject.SetActive(true);

        hudActionMap = new Dictionary <HudAction, VoidFunc> {
            { HudAction.ToggleTyping, ToggleTyping }
        };

        deathPanel   = transform.FindChild("HeroHud/DeathPanel").gameObject;
        resurrectBtn = deathPanel.transform.FindChild("ResurrectBtn").GetComponent <Button>();
        resurrectBtn.onClick.AddListener(hero.heroCombat.Resurrect);

        // find all the hud objects on the screen
        heroStatusBar = transform.FindChild("HeroHud/HeroStatusBar").gameObject;
        heroName      = heroStatusBar.transform.FindChild("HeroName").GetComponent <TextMeshProUGUI>();
        health        = heroStatusBar.transform.FindChild("HealthBar/Health").GetComponent <Image>();
        healthText    = heroStatusBar.transform.FindChild("HealthBar/HealthText").GetComponent <TextMeshProUGUI>();

        targetStatusBar = transform.FindChild("HeroHud/TargetStatusBar").gameObject;
        targetStatusBar.SetActive(false);
        targetName       = targetStatusBar.transform.FindChild("TargetName").GetComponent <TextMeshProUGUI>();
        targetHealth     = targetStatusBar.transform.FindChild("HealthBar/Health").GetComponent <Image>();
        targetHealthText = targetStatusBar.transform.FindChild("HealthBar/HealthText").GetComponent <TextMeshProUGUI>();

        heroName.text     = netId.ToString();
        health.fillAmount = (float)heroCombat.health / (float)heroCombat.maxHealth;
        healthText.text   = "Health: " + heroCombat.health + " / " + heroCombat.maxHealth;

        // setup events
        heroCombat.OnTargetChanged += UpdateTarget;
        heroCombat.OnHealthChanged += UpdateHealth;
    }
Esempio n. 5
0
    public override bool IsLegal(HeroManager hero)
    {
        if (hero.heroCombat.target == null)
        {
            return(false);
        }

        HeroCombat combat    = hero.heroCombat;
        Vector3    self      = combat.self.characterController.bounds.center;
        Vector3    target    = combat.target.characterController.bounds.center;
        Vector3    targetDir = target - self;
        RaycastHit hit;
        Vector3    lineOfSightStart = self + combat.self.transform.forward.normalized * 0.325f;

        float distance      = Vector3.Distance(self, target);
        bool  inLineOfSight = Physics.Linecast(lineOfSightStart, target, out hit) && hit.transform == combat.target.transform;
        bool  facingTarget  = Vector3.Angle(combat.self.transform.forward, targetDir) < 90.0f;
        bool  targetDead    = combat.target.heroCombat.health == 0;

        return(distance < 30.0f && inLineOfSight && facingTarget && !targetDead);
    }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        hero       = GetComponent <HeroManager>();
        heroCombat = hero.heroCombat;
        heroGlobalDisplayTransform = transform.FindChild("HeroGlobalDisplay");

        // find all the hud objects on the screen
        heroStatusBar = heroGlobalDisplayTransform.FindChild("HeroStatusBar").transform;
        heroName      = heroStatusBar.FindChild("HeroName").GetComponent <TextMeshProUGUI>();
        health        = heroStatusBar.FindChild("HealthBar/Health").GetComponent <Image>();

        if (isLocalPlayer)
        {
            heroName.fontSharedMaterial = Resources.Load("FontsMaterials/LiberationSans SDF - Green Glow") as Material;
            health.sprite = selfHealthSprite;
            health.color  = Color.white;
        }

        heroName.text     = netId.ToString();
        health.fillAmount = (float)heroCombat.health / (float)heroCombat.maxHealth;

        heroCombat.OnHealthChanged += UpdateHealth;
    }
 // Start is called before the first frame update
 void Start()
 {
     heroCombatScript = GameObject.FindGameObjectWithTag("Player").GetComponent <HeroCombat>();
 }
Esempio n. 8
0
 void Start()
 {
     selectedHero = GameObject.FindGameObjectWithTag("Player");
     heroCombat   = gameObject.GetComponent <HeroCombat>();
 }
Esempio n. 9
0
 void Start()
 {
     agent      = GetComponent <NavMeshAgent>();
     heroCombat = GetComponent <HeroCombat>();
 }
 // Start is called before the first frame update
 void Start()
 {
     agent            = gameObject.GetComponent <NavMeshAgent>();
     heroCombatScript = GetComponent <HeroCombat>();
 }