Esempio n. 1
0
    void Start()
    {
        // set ondeath listener
        HealthResource damageable = GetComponent <HealthResource>();

        damageable.onDeath.AddListener(FeedDataFragments);
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        sayHello();
        HealthResource health = GetComponent <HealthResource>();

        health.onDeath.AddListener(sayGoodbye);
    }
Esempio n. 3
0
    void Start()
    {
        // locate player
        var player = GameObject.FindGameObjectWithTag("Player");

        // if there is no player, there is no meaning to our life
        if (player == null)
        {
            enabled = false;
            return;
        }

        rb     = GetComponent <Rigidbody>();
        health = GetComponent <HealthResource>();

        recovering           = false;
        timerRunning         = false;
        goal                 = player.transform;
        oldPos               = goal.position;
        agent                = GetComponent <NavMeshAgent>();
        agent.updateRotation = true;

        if (agent.isOnNavMesh)
        {
            agent.destination = goal.position;
        }

        // activated 2nd gun if upgrade
        if (GameData.Instance.betterRangedGruntUnlocked)
        {
            leftGun.SetActive(true);
            pap.enabled = true;
        }
    }
Esempio n. 4
0
 private void Start()
 {
     damage  = GetComponent <DamageResource>();
     stamina = GetComponent <StaminaResource>();
     health  = GetComponent <HealthResource>();
     player  = GameObject.FindGameObjectWithTag("Player");
 }
Esempio n. 5
0
    public void OnDeath(HealthResource health)
    {
        //Debug.Log("You deaded!");
        //health.RestoreFullHealth();

        //deathScreenElement.SetActive(true);
        //this.Delayed(2.0f, () => deathScreenElement.SetActive(false));

        if (afterDeathCoroutine == null)
        {
            afterDeathCoroutine = StartCoroutine(AfterDeadedCoroutine());
        }
    }
Esempio n. 6
0
 public HealthViewResource(HealthResource health, GenericResource gen, MapData map)
 {
     Id            = health.Id;
     ResourceId    = health.ResourceId;
     ProvidesTests = health.ProvidesTests;
     TestPrice     = health.TestPrice;
     Gpsn          = map.Gpsn;
     Gpsw          = map.Gpsw;
     Address       = map.Address;
     City          = map.City;
     State         = map.State;
     Name          = gen.Title;
     Description   = gen.Comment;
 }
Esempio n. 7
0
    void OnTriggerEnter(Collider collider)
    {
        //Debug.Log("collided with " + collider.gameObject.name);

        // dont hit gun itself
        if (collider.GetComponentInParent <Gun>() != null)
        {
            return;
        }

        if (collider.GetComponent <ShieldPanel>() != null)
        {
            return;
        }

        // we are allowed to cross the streams
        if (collider.GetComponent <Projectile>() != null)
        {
            return;
        }

        HealthResource health = collider.gameObject.GetComponentInParent <HealthResource>();

        if (health != null)
        {
            health.ChangeValue(-damageAmount);
        }

        /*
         * // damage enemies
         * Enemy enemy = collider.gameObject.GetComponent<Enemy>();
         * if (enemy != null)
         *  enemy.OnDamage(damageAmount);
         * SuicideEnemy enemy2 = collider.gameObject.GetComponent<SuicideEnemy>();
         * if (enemy2 != null)
         *  enemy2.OnDamage(damageAmount);
         *
         * // damage player
         * HackerPlayer player = collider.gameObject.GetComponent<HackerPlayer>();
         * if (player != null)
         *  player.OnDamage(damageAmount);
         *
         * // damage master
         * MasterEye masterEye = collider.gameObject.GetComponentInParent<MasterEye>();
         * if (masterEye != null)
         *  masterEye.OnDamage(damageAmount);
         */

        Destroy(gameObject);
    }
Esempio n. 8
0
 public HealthViewResourceService(
     HealthResourceServices serv,
     HealthResource health,
     GenericResource gen,
     MapData map)
 {
     Id            = serv.Id;
     ResourceId    = health.Id;
     ProvidesTests = health.ProvidesTests;
     TestPrice     = health.TestPrice;
     Gpsn          = map.Gpsn;
     Gpsw          = map.Gpsw;
     Address       = map.Address;
     City          = map.City;
     State         = map.State;
     Name          = gen.Title;
     Description   = gen.Comment;
     ServiceName   = serv.ServiceName;
     ServiceDesc   = serv.ServiceDesc;
     AvgWaitHours  = serv.AvgWaitHours;
     EstCost       = serv.EstCost;
 }
Esempio n. 9
0
    public void OnDeath(HealthResource health)
    {
        Debug.Log("Master death");

        // explosion only visible to hacker
        GameObject explosion = Instantiate(deathExplosion, transform.position, Quaternion.identity);

        explosion.layer = LayerMask.NameToLayer("NotVisibleToMaster");

        // start video, enable overlay with render texture, disable glow
        signalLostPlayer.Play();
        signalLostBackground.SetActive(true);

        // has to be at end of frame because OnDeath gets called in OnTriggerEnter
        // and disabling MKGlow destroys some GameObjects and that is not allowed in Collision functions
        this.Delayed(new WaitForEndOfFrame(), () => mkGlow.enabled = false);

        // shrink eye
        Vector3 initialScale = transform.localScale;

        this.AnimateVector(0.3f, initialScale, Vector3.zero, Util.EaseInOut01, s => transform.localScale = s);

        this.Delayed(signalLostDuration, () =>
        {
            master.enabled = false;
            // stop video, disable overlay, enable glow and restore health
            signalLostPlayer.Pause();
            signalLostBackground.SetActive(false);

            health.RestoreFullHealth();

            mkGlow.enabled = true;
            master.enabled = true;

            // expand eye
            this.AnimateVector(0.3f, Vector3.zero, initialScale, Util.EaseInOut01, s => transform.localScale = s);
        });
    }
Esempio n. 10
0
    protected override void OnTriggerDown()
    {
        if (IsCoolingDown)
        {
            if (emptySound != null)
            {
                var go = new GameObject("Empty sound");
                go.transform.position = nozzle.position;
                var audio = go.AddComponent <AudioSource>();
                audio.clip   = emptySound;
                audio.volume = 0.3f;
                audio.Play();
                Destroy(go, emptySound.length + 0.2f);
            }
            return;
        }

        CooldownFor(shootCooldown);


        // shooting
        var aimRay = GetAimRay(nozzle);

        Collider[] colliders = Physics.OverlapSphere(nozzle.position, maxRange, hitLayerMask);
        foreach (var coll in colliders)
        {
            // instead of using the transform origin of the target, use the point that was actually hit on the collider
            Vector3 pointHit      = coll.ClosestPointOnBounds(nozzle.position);
            Vector3 nozzleToPoint = pointHit - nozzle.position;

            // only include stuff in a cone in front of the nozzle
            if (Vector3.Angle(nozzleToPoint, aimRay.direction) > totalAngle / 2)
            {
                continue;
            }

            HealthResource health = coll.gameObject.GetComponentInParent <HealthResource>();
            // only include stuff that can be damaged
            if (health == null)
            {
                return;
            }

            // sanity check
            if (nozzleToPoint.magnitude > maxRange)
            {
                Debug.LogWarning("math has broken");
            }

            // 0 = point blank range; 1 = max range
            float distanceFalloffFactor = nozzleToPoint.magnitude / maxRange;
            float damage = maxDamageAmount * damageFalloff.Evaluate(distanceFalloffFactor);

            Debug.Log("dist=" + distanceFalloffFactor + "; dmg=" + damage, coll.gameObject);

            health.ChangeValue(-damage);
            //coll.gameObject.SetActive(false);
            //this.Delayed((damage / maxDamageAmount), () => coll.gameObject.SetActive(true));
        }


        // visual effect
        int nPoints = 100;

        Vector3[] vertices = new Vector3[nPoints + 1];
        vertices[0] = nozzle.position;
        float tanAlpha = Mathf.Tan(Mathf.Deg2Rad * totalAngle / 2.0f);

        for (int i = 1; i <= nPoints; i++)
        {
            float   r        = UnityEngine.Random.Range(0.0f, 1.0f);
            float   randZ    = (1 - r * r) * maxRange;
            Vector2 randXY   = UnityEngine.Random.insideUnitCircle * randZ * tanAlpha;
            Vector3 localPos = new Vector3(randXY.x, randXY.y, randZ);

            vertices[i] = nozzle.TransformPoint(localPos);
        }

        GameObject fxGO = new GameObject("PulseGun FX");

        fxGO.AddComponent <MeshFilter>();
        fxGO.AddComponent <MeshRenderer>().sharedMaterial = volumetricLineMaterial;
        var lineScript = fxGO.AddComponent <VolumetricLines.VolumetricLineStripBehavior>();

        lineScript.SetLineColorAtStart = true;
        lineScript.LineColor           = volumetricLineMaterial.color;
        lineScript.LineWidth           = 0.12f;
        lineScript.UpdateLineVertices(vertices);
        StartCoroutine(AnimateFX(lineScript));


        if (shootSound != null)
        {
            AudioSource.PlayClipAtPoint(shootSound, nozzle.position, 0.5f);
        }
    }
Esempio n. 11
0
    private void GetVisionTargets()
    {
        if (resourceObject != null && !vision.targets.Contains(resourceObject.gameObject))
        {
            resourceObject = null;
        }
        if (droneObject != null && !vision.targets.Contains(droneObject.gameObject))
        {
            droneObject = null;
        }
        if (faction1 != null && !vision.targets.Contains(faction1.gameObject))
        {
            faction1 = null;
        }
        if (faction2 != null && !vision.targets.Contains(faction2.gameObject))
        {
            faction2 = null;
        }
        if (territoryObject != null && !vision.targets.Contains(territoryObject.gameObject))
        {
            territoryObject = null;
        }
        if (healthObject != null && !vision.targets.Contains(healthObject.gameObject))
        {
            healthObject = null;
        }

        foreach (GameObject target in vision.targets)
        {
            //Debug.Log("Inside foreach");
            // SET UP TYPES OF OBJECTS
            if (target.GetComponent <Resource>())
            {
                if (resourceObject == null)
                {
                    resourceObject = target.GetComponent <Resource>();
                }
                else if (Vector3.Distance(target.transform.position, transform.position) < Vector3.Distance(resourceObject.transform.position, transform.position))
                {
                    resourceObject = target.GetComponent <Resource>();
                }
            }
            else if (target.GetComponent <HealthResource>())
            {
                if (healthObject == null)
                {
                    healthObject = target.GetComponent <HealthResource>();
                }
                else if (Vector3.Distance(target.transform.position, transform.position) < Vector3.Distance(healthObject.transform.position, transform.position))
                {
                    healthObject = target.GetComponent <HealthResource>();
                }
            }
            else if (target.GetComponent <Drone>())
            {
                if (droneObject == null)
                {
                    droneObject = target.GetComponent <Drone>();
                }
                else if (Vector3.Distance(target.transform.position, transform.position) < Vector3.Distance(droneObject.transform.position, transform.position))
                {
                    droneObject = target.GetComponent <Drone>();
                }
            }
            else if (target.GetComponent <Faction1>())
            {
                if (faction1 == null)
                {
                    faction1 = target.GetComponent <Faction1>();
                }
                else if (Vector3.Distance(target.transform.position, transform.position) < Vector3.Distance(faction1.transform.position, transform.position))
                {
                    faction1 = target.GetComponent <Faction1>();
                }
            }
            else if (target.GetComponent <Faction2>())
            {
                if (faction2 == null)
                {
                    faction2 = target.GetComponent <Faction2>();
                }
                else if (Vector3.Distance(target.transform.position, transform.position) < Vector3.Distance(faction2.transform.position, transform.position))
                {
                    faction2 = target.GetComponent <Faction2>();
                }
            }
            else if (target.GetComponent <Territory>())
            {
                if (territoryObject == null)
                {
                    territoryObject = target.GetComponent <Territory>();
                }
                else if (Vector3.Distance(target.transform.position, transform.position) < Vector3.Distance(territoryObject.transform.position, transform.position))
                {
                    territoryObject = target.GetComponent <Territory>();
                }
            }
        }
    }
Esempio n. 12
0
 void Start()
 {
     health = GetComponent <HealthResource>();
     health.onDeath.AddListener(OnDeath);
 }