Beispiel #1
0
    private Health CreateInstance(float currentHealth, float maxHealth)
    {
        GameObject gameObject = new GameObject(string.Format("Test Health ({0})", instanceCounter++));
        Health     health     = gameObject.AddComponent <Health>();

        HealthStatsInfo stats = new HealthStatsInfo(this, currentHealth, maxHealth);

        health.SetStats(stats);
        return(health);
    }
    public virtual void Reset(IHealthSource healthSource, Transform spawnPoint) {
        HealthStatsInfo healthStatsInfo = new HealthStatsInfo(healthSource, unit.Health.Max, unit.Health.Max);
        unit.Health.SetStats(healthStatsInfo);

        movement.Reset(spawnPoint);

        foreach(Ability ability in unit.Abilities) {
            ability.Reset();
        }

        enabled = true;
        StopAll();

        unit.Ragdoll.Hide();

        unit.gameObject.SetActive(true);
    }
Beispiel #3
0
    void PrepUnits()
    {
        foreach (Unit unit in allUnits)
        {
            HealthStatsInfo healthStatsInfo = new HealthStatsInfo(this, unit.Health.Max, unit.Health.Max);
            unit.Health.SetStats(healthStatsInfo);

            int       i          = allUnits.IndexOf(unit);
            Transform spawnPoint = map.GetSpawnPoint(i);
            unit.transform.position = spawnPoint.position;
            unit.transform.rotation = spawnPoint.rotation;

            if (unit.Controller != null)
            {
                unit.Controller.StopAll();
            }

            unit.gameObject.SetActive(true);
        }
    }