Example #1
0
    private void OnDeath()
    {
        dead = true;
        currentHealths[0] = 0;
        Destroy(gameObject, 0.75F);
        foreach (SpriteRenderer renderer in GetComponentsInChildren <SpriteRenderer>())
        {
            renderer.enabled = false;
        }

        AudioManager.PlayClipByID("clip_explosion1", transform.position);
        GameObject tmp = Instantiate(explosionCirclePrefab); // instantiate circle explosion

        tmp.SetActive(true);
        tmp.transform.SetParent(transform, false);
        tmp.GetComponent <DrawCircleScript>().Initialize();
        Destroy(tmp, 1); // destroy explosions after 1 second
        for (int i = 0; i < 3; i++)
        {
            var rend = Instantiate(shard, null, false).GetComponent <SpriteRenderer>();
            rend.color = rockColors[tier];
            rend.transform.position = transform.position;
            rend.sprite             = shardSprites[Random.Range(0, 3)];
            if (i == 0)
            {
                rend.gameObject.AddComponent <Draggable>();
            }

            var shardComp = rend.GetComponent <Shard>();
            shardComp.Detach();
            if (!LocationBasedShard)
            {
                shardComp.SetCollectible(i == 0);
            }

            if (!LocationBasedShard)
            {
                AIData.rockFragments.Add(shardComp.GetComponent <Draggable>());
            }

            if (PlayerCore.Instance)
            {
                PlayerCore.Instance.cursave.locationBasedShardsFound.Add(ID);
            }

            shardComp.tier = tier;
        }

        if (LocationBasedShard && PlayerCore.Instance)
        {
            var tiers = new int[] { 1, 5, 20 };
            PlayerCore.Instance.shards += tiers[tier];
            ShardCountScript.DisplayCount(PlayerCore.Instance.shards);
        }
    }
Example #2
0
    protected override void Update()
    {
        if (!isDead)
        {
            foreach (WeaponAbility weapon in GetComponentsInChildren <WeaponAbility>())
            {
                weapon.Tick();
            }
        }
        base.Update();
        TargetManager.Enqueue(targeter);

        if (FactionManager.IsAllied(faction, 0))
        {
            if ((transform.position - PlayerCore.Instance.transform.position).sqrMagnitude <= 75)
            {
                var player = PlayerCore.Instance;
                if (player.GetTractorTarget() && (player.GetTractorTarget().GetComponent <ShellPart>() ||
                                                  player.GetTractorTarget().GetComponent <Shard>()) && !tractor.GetTractorTarget())
                {
                    tractor.SetTractorTarget(player.GetTractorTarget());
                    player.SetTractorTarget(null);
                }
            }
            if (tractor.GetTractorTarget() && (transform.position - tractor.GetTractorTarget().transform.position).sqrMagnitude <= 10)
            {
                if (tractor.GetTractorTarget().GetComponent <ShellPart>())
                {
                    PassiveDialogueSystem.Instance.PushPassiveDialogue(ID, "<color=lime>Your part has been added into your inventory.</color>");
                    var shellPart = tractor.GetTractorTarget().GetComponent <ShellPart>();
                    var info      = shellPart.info;
                    info = ShipBuilder.CullSpatialValues(info);
                    ShipBuilder.AddOriginToDictionary(shellPart);
                    PlayerCore.Instance.cursave.partInventory.Add(info);
                    PartIndexScript.AttemptAddToPartsObtained(info);
                    PartIndexScript.AttemptAddToPartsSeen(info);
                    if (NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect != null)
                    {
                        NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect.Invoke(info.partID, info.abilityID, shellPart.droppedSectorName);
                    }
                    Destroy(shellPart.gameObject);
                }
                else if (tractor.GetTractorTarget().GetComponent <Shard>())
                {
                    PassiveDialogueSystem.Instance.PushPassiveDialogue(ID, "<color=lime>Your shard has been added into your stash.</color>");
                    var shard = tractor.GetTractorTarget().GetComponent <Shard>();
                    var tiers = new int[] { 1, 5, 20 };
                    PlayerCore.Instance.shards += tiers[shard.tier];
                    ShardCountScript.DisplayCount(PlayerCore.Instance.shards);
                    Destroy(shard.gameObject);
                }
            }
        }
    }
Example #3
0
    protected override void Update()
    {
        if (!isDead)
        {
            foreach (WeaponAbility weapon in GetComponentsInChildren <WeaponAbility>())
            {
                weapon.Tick();
            }
        }

        base.Update();
        TargetManager.Enqueue(targeter);

        if (PlayerCore.Instance && FactionManager.IsAllied(faction, PlayerCore.Instance.faction))
        {
            if ((transform.position - PlayerCore.Instance.transform.position).sqrMagnitude <= YardProximitySquared)
            {
                var player = PlayerCore.Instance;
                foreach (var partyMember in PartyManager.instance.partyMembers)
                {
                    if ((transform.position - partyMember.transform.position).sqrMagnitude > YardProximitySquared && !partyMember.HasRepaired && !partyMember.IsFullyRepaired())
                    {
                        partyMember.Warp(transform.position + new Vector3(Random.Range(-2, 2), Random.Range(-2, 2)));
                    }
                }


                if (!player.HasRepaired)
                {
                    if (!player.IsFullyRepaired() && !player.GetIsDead())
                    {
                        player.repairFinalized = false;
                        StartCoroutine(player.StartYardRepair());
                    }
                }
                else if (player.repairFinalized)
                {
                    player.HealToMax();
                }

                player.HasRepaired = true;
                if (player.GetTractorTarget() && (player.GetTractorTarget().GetComponent <ShellPart>() ||
                                                  player.GetTractorTarget().GetComponent <Shard>()) && !tractor.GetTractorTarget())
                {
                    tractor.SetTractorTarget(player.GetTractorTarget());
                    player.SetTractorTarget(null);
                }
            }

            foreach (var partyMember in PartyManager.instance.partyMembers)
            {
                if (partyMember && partyMember.GetAI().getMode() == AirCraftAI.AIMode.Follow &&
                    (transform.position - partyMember.transform.position).sqrMagnitude <= YardProximitySquared)
                {
                    if (!partyMember.HasRepaired)
                    {
                        if (!partyMember.IsFullyRepaired() && !partyMember.GetIsDead())
                        {
                            partyMember.repairFinalized = false;
                            StartCoroutine(partyMember.StartYardRepair());
                        }
                    }
                    else if (partyMember.repairFinalized)
                    {
                        partyMember.HealToMax();
                    }
                    partyMember.HasRepaired = true;
                }
            }

            if (tractor.GetTractorTarget() && (transform.position - tractor.GetTractorTarget().transform.position).sqrMagnitude <= 10)
            {
                if (tractor.GetTractorTarget().GetComponent <ShellPart>())
                {
                    PassiveDialogueSystem.Instance.PushPassiveDialogue(ID, "<color=lime>Your part has been added into your inventory.</color>", 4);
                    var shellPart = tractor.GetTractorTarget().GetComponent <ShellPart>();
                    var info      = shellPart.info;
                    info = ShipBuilder.CullSpatialValues(info);
                    ShipBuilder.AddOriginToDictionary(shellPart);
                    PlayerCore.Instance.cursave.partInventory.Add(info);
                    PartIndexScript.AttemptAddToPartsObtained(info);
                    PartIndexScript.AttemptAddToPartsSeen(info);
                    if (NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect != null)
                    {
                        NodeEditorFramework.Standard.YardCollectCondition.OnYardCollect.Invoke(info.partID, info.abilityID, shellPart.droppedSectorName);
                    }

                    Destroy(shellPart.gameObject);
                }
                else if (tractor.GetTractorTarget().GetComponent <Shard>())
                {
                    PassiveDialogueSystem.Instance.PushPassiveDialogue(ID, "<color=lime>Your shard has been added into your stash.</color>", 4);
                    var shard = tractor.GetTractorTarget().GetComponent <Shard>();
                    var tiers = new int[] { 1, 5, 20 };
                    PlayerCore.Instance.shards += tiers[shard.tier];
                    ShardCountScript.DisplayCount(PlayerCore.Instance.shards);
                    Destroy(shard.gameObject);
                }
            }
        }
    }
Example #4
0
    private void GrabCollectiblesFromAllies()
    {
        var currentTarget = tractor.GetTractorTarget();

        if (currentTarget)
        {
            if (currentTarget && (transform.position - currentTarget.transform.position).sqrMagnitude <= 10)
            {
                if (currentTarget.GetComponent <ShellPart>())
                {
                    TakePart(GetComponent <Entity>(), tractor);
                }
                else if (currentTarget.GetComponent <Shard>())
                {
                    PassiveDialogueSystem.Instance.PushPassiveDialogue(ID, "<color=lime>Your shard has been added into your stash.</color>", 4);
                    var shard = currentTarget.GetComponent <Shard>();
                    var tiers = new int[] { 1, 5, 20 };
                    PlayerCore.Instance.shards += tiers[shard.tier];
                    ShardCountScript.DisplayCount(PlayerCore.Instance.shards);
                    Destroy(shard.gameObject);
                }
            }
        }
        else
        {
            var player = PlayerCore.Instance;

            if ((transform.position - player.transform.position).sqrMagnitude < YardProximitySquared)
            {
                var playerTractor = player.GetComponentInChildren <TractorBeam>();

                if (playerTractor)
                {
                    var target = playerTractor.GetTractorTarget();

                    if (target && (target.GetComponent <ShellPart>() || target.GetComponent <Shard>()))
                    {
                        playerTractor.SetTractorTarget(null);
                        tractor.SetTractorTarget(target);

                        // Bad boy return here to prevent from looking into worker
                        // drones if already got something from the player.
                        return;
                    }
                }
            }

            foreach (Entity entity in player.GetUnitsCommanding())
            {
                if ((transform.position - entity.transform.position).sqrMagnitude > YardProximitySquared)
                {
                    continue;
                }

                var entityTractor = entity.GetComponentInChildren <TractorBeam>();

                if (!entityTractor)
                {
                    continue;
                }

                var target = entityTractor.GetTractorTarget();

                if (target && (target.GetComponent <ShellPart>() || target.GetComponent <Shard>()))
                {
                    entityTractor.SetTractorTarget(null);
                    tractor.SetTractorTarget(target);
                    break;
                }
            }
        }
    }