Esempio n. 1
0
    private void HandleFloatingTextSpawnNotification(FloatingTextObject textObject)
    {
        GameObject moveLocation = GameObject.Find("Loc (" + textObject.coordinates.x + ", "
                                                  + textObject.coordinates.y + ")");

        StartCoroutine(SpawnHazardForEvasion(moveLocation.transform.position));
    }
Esempio n. 2
0
    private void TriggerEvasion(FloatingTextObject textObject)
    {
        string locationName =
            "Loc (" + textObject.coordinates.x + ", " + textObject.coordinates.y + ")";

        StartCoroutine(Evade(locationName, GetMoveVector(textObject.arrowDirection)));
    }
Esempio n. 3
0
    private void ReplaceTextWithDirection(FloatingTextObject textObject)
    {
        switch (textObject.arrowDirection)
        {
        case ArrowDirection.Up:
            textObject.textToDisplay = "Up";
            break;

        case ArrowDirection.Down:
            textObject.textToDisplay = "Down";
            break;

        case ArrowDirection.Left:
            textObject.textToDisplay = "Left";
            break;

        case ArrowDirection.Right:
            textObject.textToDisplay = "Right";
            break;

        default:
            Debug.Log(
                name +
                ": SpawnTime " +
                textObject.spawnTime +
                "replaceTextWithDirection was checked but no ArrowDirection was assigned."
                );
            break;
        }
    }
Esempio n. 4
0
    private Vector2 AssignCoordinatesAndArrowDirection(FloatingTextObject textObject, Vector2 currentPosition)
    {
        Vector2 newMoveLocation;
        int     randomDirectionValue = (int)Mathf.Sign(Random.Range(-1, 1));       // returns  -1 or 1

        // Choose a random axis
        if (Random.Range(0, 2) == 0)
        {
            // x axis
            if (randomDirectionValue + currentPosition.x > 2 || randomDirectionValue + currentPosition.x < -2)
            {
                randomDirectionValue = -randomDirectionValue;
            }
            newMoveLocation           = new Vector2(randomDirectionValue + currentPosition.x, currentPosition.y);
            textObject.arrowDirection = AssignArrowDirection(randomDirectionValue, Axis.x);
        }
        else
        {
            // y axis
            if (randomDirectionValue + currentPosition.y > 2 || randomDirectionValue + currentPosition.y < -2)
            {
                randomDirectionValue = -randomDirectionValue;
            }
            newMoveLocation           = new Vector2(currentPosition.x, randomDirectionValue + currentPosition.y);
            textObject.arrowDirection = AssignArrowDirection(randomDirectionValue, Axis.y);
        }

        if (textObject.replaceTextWithDirection == true)
        {
            ReplaceTextWithDirection(textObject);
        }

        textObject.coordinates = newMoveLocation;
        return(newMoveLocation);
    }
Esempio n. 5
0
    private void SpawnArrow(FloatingTextObject textObject)
    {
        GameObject arrow;

        switch (textObject.arrowDirection)
        {
        case ArrowDirection.Up:
            arrow = Instantiate(arrows [0]);
            break;

        case ArrowDirection.Down:
            arrow = Instantiate(arrows [1]);
            break;

        case ArrowDirection.Left:
            arrow = Instantiate(arrows [2]);
            break;

        case ArrowDirection.Right:
            arrow = Instantiate(arrows [3]);
            break;

        default:
            arrow = Instantiate(arrows [Random.Range(0, 4)]);
            Debug.Log(name + ": Arrow direction has not been set. Please check SpawnArrow(FloatingTextObject) function.");
            break;
        }

        arrow.GetComponent <ArrowObject>().textObject = textObject;
    }
 private void RemoveWordFromList(FloatingTextObject floatingText)
 {
     if (listOfTextPrompts.Count > 0)
     {
         listOfTextPrompts.RemoveAt(0);
         //Debug.Log ("textPrompts: " + listOfTextPrompts.Count);
     }
 }
Esempio n. 7
0
    private void BroadcastText(FloatingTextObject textObject)
    {
        GameObject container = Instantiate(wordContainer);

        container.GetComponent <FloatingTextContainer>().floatingTextObject = textObject;

        if (floatingTextNotification != null)
        {
            floatingTextNotification(textObject);
        }
        else
        {
            Debug.Log(name + ": No FloatingTextNotification.");
        }

        listOfText.Remove(textObject);
    }
 private void AddWordToList(FloatingTextObject floatingText)
 {
     listOfTextPrompts.Add(floatingText);
 }
Esempio n. 9
0
 private void HandleFloatingTextSpawnNotification(FloatingTextObject textObject)
 {
     SpawnArrow(textObject);
 }