示例#1
0
        IEnumerator pathPlayer(PlayerCore player)
        {
            player.SetIsInteracting(false);
            PathData.Node current = GetNode(0);

            while (current != null)
            {
                Vector2 delta = current.position - (Vector2)player.transform.position - player.GetComponent <Rigidbody2D>().velocity *Time.fixedDeltaTime;
                player.MoveCraft(delta.normalized);
                if (delta.sqrMagnitude < PathAI.minDist)
                {
                    if (current.children.Count > 0)
                    {
                        int next = Random.Range(0, current.children.Count);
                        current = GetNode(current.children[next]);
                    }
                    else
                    {
                        current = null;
                    }
                }

                yield return(null);
            }

            player.SetIsInteracting(true);

            if (!asynchronous)
            {
                continueTraversing();
            }
        }
示例#2
0
    public void initialize()
    {
        instance = this;
        player.SetIsInteracting(true);

        Activate();
        gameObject.SetActive(true);
        drawScreen();
        // TODO: Fix the shard count script
        ShardCountScript.StickySlideIn(player.shards);
    }
示例#3
0
    private void Update()
    {
        if (jsonMode)
        {
            player.SetIsInteracting(true);
        }
        if (!jsonMode && player && (current == null || (!current.bounds.contains(player.transform.position) && !player.GetIsOscillating())))
        {
            AttemptSectorLoad();
        }

        // deadzone damage
        if (current && current.type == Sector.SectorType.DangerZone)
        {
            if (dangerZoneTimer >= 5 && !player.GetIsDead())
            {
                dangerZoneTimer = 0;
                Instantiate(damagePrefab, player.transform.position, Quaternion.identity);
                player.TakeShellDamage(0.2F * player.GetMaxHealth()[0], 0, null);
                player.TakeCoreDamage(0.2F * player.GetMaxHealth()[1]);
                player.alerter.showMessage("WARNING: Leave Sector!", "clip_stationlost");
            }
            else
            {
                dangerZoneTimer += Time.deltaTime;
            }
        }
        else
        {
            dangerZoneTimer = 0;
        }

        if (!DialogueSystem.isInCutscene)
        {
            bgSpawnTimer += Time.deltaTime;

            if (bgSpawnTimer >= 8 && bgSpawns.Count > 0)
            {
                bgSpawnTimer = 0;
                var key        = bgSpawns[Random.Range(0, bgSpawns.Count)];
                var spawnPoint = player.transform.position + Quaternion.Euler(0, 0, Random.Range(0, 360)) * new Vector3(key.Item4, 0, 0);
                key.Item2.position = spawnPoint;
                key.Item2.ID       = "";
                SpawnEntity(key.Item1, key.Item2);
                AudioManager.PlayClipByID("clip_respawn", spawnPoint);
            }
        }
    }
示例#4
0
    public void InitializeSelectionPhase()
    {
        searcherString = "";
        selectionPhaseParent.SetActive(true);
        buildPhaseParent.SetActive(false);
        //initialize window on screen
        if (initialized)
        {
            CloseUI(false);                     // prevent initializing twice by closing UI if already initialized
        }
        initialized = true;
        Activate();
        cursorScript.gameObject.SetActive(false);
        cursorScript.SetBuilder(this);

        contentsArray = new Transform[] { smallContents, mediumContents, largeContents };
        contentTexts  = new GameObject[] { smallText, mediumText, largeText };
        foreach (GameObject obj in contentTexts)
        {
            obj.SetActive(false);
        }

        GetComponentInChildren <ShipBuilderPartDisplay>().Initialize(this);
        player.SetIsInteracting(true);
        partDict = new Dictionary <DWInventoryButton, EntityBlueprint.PartInfo>();

        // hide the buttons and yard tips if interacting with a trader

        List <EntityBlueprint.PartInfo> parts = player.GetInventory();

        if (parts != null)
        {
            for (int i = 0; i < parts.Count; i++)
            {
                parts[i] = ShipBuilder.CullSpatialValues(parts[i]);
            }
        }

        foreach (EntityBlueprint.PartInfo part in parts)
        {
            if (part.abilityID == 10)
            {
                AddDronePart(part);
            }
        }
        foreach (EntityBlueprint.PartInfo part in player.blueprint.parts)
        {
            if (part.abilityID == 10)
            {
                AddDronePart(part);
            }
        }

        var partsToAdd = new List <ShellPart>();

        foreach (Entity ent in player.GetUnitsCommanding())
        {
            if (!((ent as Drone) && ent.GetComponentInChildren <TractorBeam>()))
            {
                continue;
            }
            var target = ent.GetComponentInChildren <TractorBeam>().GetTractorTarget();
            if (target && target.GetComponent <ShellPart>())
            {
                partsToAdd.Add(target.GetComponent <ShellPart>());
            }
        }

        if (player.GetTractorTarget() && player.GetTractorTarget().GetComponent <ShellPart>())
        {
            partsToAdd.Add(player.GetTractorTarget().GetComponent <ShellPart>());
        }

        foreach (ShellPart part in partsToAdd)
        {
            var info = part.info;
            info = ShipBuilder.CullSpatialValues(info);
            if (info.abilityID == 10)
            {
                int size   = ResourceManager.GetAsset <PartBlueprint>(info.partID).size;
                var button = Instantiate(displayButtonPrefab, contentsArray[size]).GetComponent <DWInventoryButton>();
                button.handler  = selectionDisplay;
                button.workshop = this;
                contentTexts[size].SetActive(true);
                button.part = info;
                partDict.Add(button, info);
            }
            player.cursave.partInventory.Add(info);
            Destroy(part.gameObject);
        }
        phase = DroneWorkshopPhase.SelectionPhase;
        // activate windows
        gameObject.SetActive(true);
    }