예제 #1
0
    // Update is called once per frame
    private void Update()
    {
        if (initialized) // check if safe to update
        {
            for (int i = 0; i < core.GetAbilities().Length; i++)
            {
                // update all abilities
                if (abilities[i] == null || core.GetIsDead())
                {
                    continue;
                }

                // skip ability instead of break because further abilities may not be destroyed
                if (visibleAbilities.Contains(abilities[i]))
                {
                }
                else //abilities[i].UpdateState();
                {
                    abilities[i].Tick();
                }
            }

            if (core.GetIsDead() || core.GetIsInteracting())
            {
                return;
            }

            if (InputManager.GetKeyDown(KeyName.ShowSkills))
            {
                SetCurrentVisible(AbilityTypes.Skills);
            }

            if (InputManager.GetKeyDown(KeyName.ShowSpawns))
            {
                SetCurrentVisible(AbilityTypes.Spawns);
            }

            if (InputManager.GetKeyDown(KeyName.ShowWeapons))
            {
                SetCurrentVisible(AbilityTypes.Weapons);
            }

            if (InputManager.GetKeyDown(KeyName.ShowPassives))
            {
                SetCurrentVisible(AbilityTypes.Passive);
            }
        }
    }
예제 #2
0
    private void Update()
    {
        if (window && speakerPos != null && player &&
            ((player.transform.position - ((Vector3)speakerPos)).sqrMagnitude > 100 || player.GetIsDead()) && !isInCutscene)
        {
            endDialogue();
        }

        // reset window position if dialogue is over
        if (!window)
        {
            lastPosition = DialogueWindowPosition.None;
        }

        // Add text
        if (textRenderer && characterCount < text.Length)
        {
            if (Time.time > nextCharacterTime)
            {
                characterCount++;
                nextCharacterTime = (float)(Time.time + timeBetweenCharacters);
                textRenderer.text = text.Substring(0, characterCount);
            }
        }
    }
예제 #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
    void Update()
    {
        if (player != null)
        {
            closest = null; // get the closest entity
            foreach (IInteractable interactable in AIData.interactables)
            {
                if (interactable as PlayerCore || interactable == null || !interactable.GetInteractible())
                {
                    continue;
                }

                if (closest == null)
                {
                    closest = interactable;
                }
                else if ((interactable.GetTransform().position - player.transform.position).sqrMagnitude <=
                         (closest.GetTransform().position - player.transform.position).sqrMagnitude)
                {
                    closest = interactable;
                }
            }

            if (closest is IVendor vendor)
            {
                var blueprint = vendor.GetVendingBlueprint();
                var range     = blueprint.range;

                if (!player.GetIsDead() && (closest.GetTransform().position - player.transform.position).sqrMagnitude <= range)
                {
                    for (int i = 0; i < blueprint.items.Count; i++)
                    {
                        if (InputManager.GetKey(KeyName.TurretQuickPurchase))
                        {
                            if (Input.GetKeyDown((1 + i).ToString()))
                            {
                                vendorUI.SetVendor(vendor, player);
                                vendorUI.onButtonPressed(i);
                            }
                        }
                    }
                }
            }
        }
    }
예제 #5
0
    public void next(Dialogue dialogue, int ID, Entity speaker)
    {
        if (dialogue.nodes.Count == 0)
        {
            Debug.LogWarning("Empty dialogue: " + dialogue.name);
            endDialogue(0, false);
            return;
        }

        if (player.GetIsDead())
        {
            Debug.Log("Dead player");
            endDialogue(0, false);
            return;
        }

        // clear everything
        if (buttons != null)
        {
            for (int i = 0; i < buttons.Length; i++)
            {
                Destroy(buttons[i]);
            }
        }

        // find dialogue index
        int currentIndex = getNodeIndex(dialogue, ID);

        if (currentIndex == -1)
        {
            Debug.LogWarning("Missing node '" + ID + "' in " + dialogue.name);
            endDialogue();
            return;
        }
        Dialogue.Node current = dialogue.nodes[currentIndex];

        // check if the node has an action
        switch (current.action)
        {
        case Dialogue.DialogueAction.None:
            AudioManager.PlayClipByID("clip_typing", true);
            break;

        case Dialogue.DialogueAction.Outpost:
            endDialogue(0, false);
            if (speaker.faction != player.faction)
            {
                return;
            }
            if (((Vector3)speakerPos - player.transform.position).magnitude < dialogue.vendingBlueprint.range)
            {
                vendorUI.SetVendor(speaker as IVendor, player);
                vendorUI.openUI();
            }
            endDialogue(0, false);
            return;

        case Dialogue.DialogueAction.Shop:
            OpenTrader((Vector3)speakerPos, dialogue.traderInventory);
            endDialogue(0, false);
            return;

        case Dialogue.DialogueAction.Yard:
            OpenBuilder((Vector3)speakerPos);
            endDialogue(0, false);
            return;

        case Dialogue.DialogueAction.Exit:
            endDialogue(0, true);
            return;

        case Dialogue.DialogueAction.Workshop:
            workshop.yardPosition = (Vector3)speakerPos;
            workshop.InitializeSelectionPhase();
            endDialogue(0, false);
            return;

        case Dialogue.DialogueAction.Upgrader:
            upgraderScript.initialize();
            endDialogue(0, false);
            return;

        default:
            break;
        }

        // radio image
        window.GetComponentInChildren <SelectionDisplayHandler>().AssignDisplay(speaker.blueprint, null);
        window.transform.Find("Name").GetComponent <Text>().text = speaker.blueprint.entityName;

        // change text
        text               = current.text.Replace("<br>", "\n");
        characterCount     = 0;
        nextCharacterTime  = (float)(Time.time + timeBetweenCharacters);
        textRenderer.color = current.textColor;

        // create buttons
        buttons = new GameObject[current.nextNodes.Count];

        for (int i = 0; i < current.nextNodes.Count; i++)
        {
            int nextIndex = getNodeIndex(dialogue, current.nextNodes[i]);
            if (nextIndex == -1)
            {
                Debug.LogWarning("Missing node '" + current.nextNodes[i] + "' in " + dialogue.name);
                endDialogue();
                return;
            }
            Dialogue.Node next = dialogue.nodes[nextIndex];

            Transform button = CreateButton(next.buttonText, null, 24 + 16 * (current.nextNodes.Count - (i + 1))).transform;

            button.GetComponent <Button>().onClick.AddListener(() => {
                Next(dialogue, nextIndex, speaker);
            });
            if (dialogue.nodes[nextIndex].action != Dialogue.DialogueAction.Exit)
            {
                button.GetComponent <Button>().onClick.AddListener(() => {
                    AudioManager.PlayClipByID("clip_select", true);
                    // need condition to ensure no sound clashes occur
                });
            }

            buttons[i] = button.gameObject;
        }
    }