public override void Interact(PlayerStamina playerStamina)
    {
        CreateTextbox.Create(Name, Text + "\nThis costs <color=blue>" + price + " gems</color>.");
        CreateTextbox.Create(Name, new string[] { "Buy", "Cancel" }, true, true,
                             selection => {
            switch (selection)
            {
            // Buy
            case 0:
                if (playerStamina.Gems >= price)
                {
                    if (playerStamina.HasItem)
                    {
                        CreateTextbox.Create(Name, "You're already holding an item...");
                    }
                    else
                    {
                        playerStamina.AddGems(-price);
                        playerStamina.Item = item;
                        CreateTextbox.Create(Name, "Come again!");
                    }
                }
                else
                {
                    CreateTextbox.Create(Name, "You don't have enough <color=blue>gems</color>...");
                }
                break;

            // Cancel
            case 1:
                CreateTextbox.Create(Name, "Come again!");
                break;
            }
        });
    }
Пример #2
0
    public void OnOpen(PlayerStamina player)
    {
        if (!open)
        {
            player.AddGems(gems);
            open = true;
            GetComponent <MeshFilter>().mesh = openMesh;
            Material material = GetComponent <MeshRenderer>().material;
            material.SetTexture("_MainTex", openTex);
            material.SetTexture("_BumpMap", openMap);

            CreateTextbox.Create("Chest", "You found <color=blue>" + gems.ToString() + " gems</color>!");
            Opened();
        }
    }
Пример #3
0
    void OnTriggerEnter(Collider collider)
    {
        if (collider.gameObject.CompareTag("Hazard"))
        {
            StartCoroutine("Die");
        }
        if (collider.gameObject.CompareTag("Trap"))
        {
            if (!hasTrapped)
            {
                CreateTextbox.Create("You", "You fell into a trap! <color=blue>Shake the tablet</color> to escape.");
                hasTrapped = true;
            }
            playerMove.Trapped = true;
            Destroy(collider.gameObject);
        }
        if (collider.gameObject.CompareTag("TextTrigger"))
        {
            CreateTextbox.Close();
            Destroy(collider.gameObject);
        }
        if (collider.gameObject.CompareTag("FinalTrigger"))
        {
            GameObject.Find("Pyramid").GetComponent <PyramidController>().FinalText();
            Destroy(collider.gameObject);
        }
        if (collider.gameObject.CompareTag("Door"))
        {
            CreateTextbox.Create("You", "Would you like to leave the tutorial?", false, true,
                                 result => CreateTextbox.Create("You", new string[] { "Leave", "Stay" },
                                                                true, true,
                                                                answer => {
                switch (answer)
                {
                // Leave
                case 0:
                    Application.Quit();
                    break;

                // Stay
                case 1:
                    CreateTextbox.Clear();
                    break;
                }
            }));
        }
    }
    void Start()
    {
        // Get list of markers
        markers = new List <GameObject>(FindObjectsOfType <GameObject>());
        markers.RemoveAll(gameObj => gameObj.CompareTag("PyramidMarker") == false);
        // Sort markers by distance
        markers.Sort(new MarkerComparer(transform.position));

        CreateTextbox.Create("Pyramid",
                             "Welcome to my Dungeon of Doom! First things first. <color=blue>Tap the screen</color> to move around. You only need a tap, no need to hold it down.",
                             false, false, answer => NextMarker());
        CreateTextbox.Create("Pyramid",
                             "Hmm. The ball shows some promise. But I bet you'll never figure out you can <color=blue>press Z to jump</color> up these platforms!",
                             false, false, answer => NextMarker());
        CreateTextbox.Create("Pyramid", "Excellent. I wonder if you realise you can perform <color=blue>wall jumps</color> by jumping into a wall, then <color=blue>jumping again</color>...",
                             false, false, answer => NextMarker());
        CreateTextbox.Create("Pyramid", "Did I mention that you can roll? <color=blue>Press X to roll</color> forward quickly. You'll need to use it after hitting this switch. Oh, and try not to die.",
                             false, false, answer => NextMarker());
        CreateTextbox.Create("Pyramid", "Very clever. You're probably feeling mighty proud of yourself, and after all that hard work, you deserve a reward. <color=blue>Press X to open</color> this chest.",
                             false, true, answer => NextMarker());
    }
Пример #5
0
 public virtual void Interact(PlayerStamina playerStamina)
 {
     CreateTextbox.Create(Name, Text);
 }
 public void FinalText()
 {
     CreateTextbox.Create("Pyramid", "Well, I'm getting bored of following you around like this, so you will have to continue alone. Fear not, I will be watching intently...",
                          false, true);
 }
Пример #7
0
    void Update()
    {
        if (!(Input.GetKeyDown(KeyCode.X) && CreateTextbox.Continue()) && !Trapped)
        {
            // Find any closed nearby chests
            nearChest = false;
            GameObject nearbyChest = chests.Find(gameObj =>
                                                 gameObj.GetComponent <ChestController>().Open == false &&
                                                 (transform.position - gameObj.transform.position).magnitude < chestRange
                                                 );
            if (nearbyChest != null)
            {
                nearChest = true;
            }
            // Find any nearby NPCs
            nearNPC = false;
            GameObject nearbyNPC = npcs.Find(gameObj =>
                                             (transform.position - gameObj.transform.position).magnitude < NPCRange
                                             );
            if (nearbyNPC != null)
            {
                nearNPC = true;
            }

            // Handle X hint
            buttonObject.SetActive(nearChest || nearNPC);
            buttonObject.transform.position = Camera.main.WorldToScreenPoint(transform.position)
                                              + buttonOffset * Vector3.up;

            if (!playerJump.Dying && Input.GetKeyDown(KeyCode.X))
            {
                if (!rolling)
                {
                    if (nearChest)
                    {
                        nearbyChest.GetComponent <ChestController>().OnOpen(playerStamina);
                    }
                    else if (nearNPC)
                    {
                        nearbyNPC.GetComponent <NPCController>().Interact(playerStamina);
                    }
                    else
                    {
                        StartCoroutine("Roll");
                    }
                }
            }

            // On left mouse click
            if (Input.GetMouseButtonDown(0))
            {
                SetDestination();
            }

            // Kill non-roll auto move on the ground
            if (AutoMove && !rolling && controller.isGrounded)
            {
                AutoMove    = false;
                destination = transform.position;
            }
        }
        else
        {
            shakeAmount += Input.gyro.userAcceleration.magnitude;
            if (shakeAmount > TrapShake)
            {
                shakeAmount = 0;
                Trapped     = false;
            }
        }
    }