Ejemplo n.º 1
0
 void Start()
 {
     player           = Toolbox.Instance.GetPlayer();
     mainCamera       = Camera.main;
     textComponent    = GetComponentInChildren <Text>();
     originalFontSize = textComponent.fontSize;
     textAndImage     = transform.GetChild(0).gameObject;
     fileText         = textFile.text.Split(new string[] { "****\n", "****\r\n", "****" }, StringSplitOptions.None);
     iLetter          = 0;
     iParagraph       = 0;
     dState           = DistanceState.Inactive;
     sState           = SubState.Writing;
     DisableTextAndImage();
     InvokeRepeating("SetPlayerDistance", 0, refreshTime);
 }
Ejemplo n.º 2
0
        public void Update(Hero9 myHero)
        {
            if (!this.unit.IsAlive || !myHero.IsAlive)
            {
                this.state = DistanceState.Far;
                return;
            }

            var heroPosition  = myHero.Position;
            var enemyPosition = this.unit.BasePosition;
            var distance      = heroPosition.Distance2D(enemyPosition);

            if (!this.unit.IsVisible)
            {
                var speed = this.UnitSpeed;
                if (speed <= 0)
                {
                    return;
                }

                var maxTime           = distance / speed;
                var invisTime         = Math.Min(maxTime, Game.RawGameTime - this.unit.LastPositionUpdateTime);
                var predictedPosition = enemyPosition.Extend2D(heroPosition, invisTime * speed);

                distance = heroPosition.Distance2D(predictedPosition);
            }

            if (distance < 2000)
            {
                this.state = DistanceState.Near;
            }
            else if (distance < 3500)
            {
                this.state = DistanceState.Close;
            }
            else
            {
                this.state = DistanceState.Far;
            }
        }
Ejemplo n.º 3
0
        public AbstractState makeState(string stateName, string p1, string p2, string p3, float precision, float grados, string stateType, int posState1, int posState2)
        {
            AbstractState aS;
            AbstractState aS1 = getState(posState1);
            AbstractState aS2 = getState(posState2);

            switch (stateType)
            {
            case "AND": aS = new AndState(aS1, aS2, stateName); break;

            case "ANGLE": aS = new AngleState(p1, p3, p2, grados, precision, stateName); break;

            case "CENTER_X": aS = new CenterStateX(p1, p2, precision, stateName); break;

            case "CENTER_Y": aS = new CenterStateY(p1, p2, precision, stateName); break;

            case "CENTER_Z": aS = new CenterStateZ(p1, p2, precision, stateName); break;

            case "DISTANCE": aS = new DistanceState(p1, p2, precision, stateName); break;

            case "LEFT": aS = new LeftState(p1, p2, precision, stateName); break;

            case "OR": aS = new OrState(aS1, aS2, stateName); break;

            case "OVER": aS = new OverState(p1, p2, precision, stateName); break;

            case "POSITION": aS = new PositionState(p1, precision, stateName); break;

            case "RIGHT": aS = new RightState(p1, p2, precision, stateName); break;

            case "UNDER": aS = new UnderState(p1, p2, precision, stateName); break;

            default: aS = new InvalidState(stateName); break;
            }
            return(aS);
        }
Ejemplo n.º 4
0
    void UpdateStates()
    {
        if (playerDistance < activeDistance)
        {
            if (dState == DistanceState.Inactive && sState != SubState.WaitingForReactivation)
            {
                EnableTextAndImage();
            }

            if (playerDistance < switchDistance)
            {
                dState = DistanceState.Active;
            }
            else
            {
                dState = DistanceState.Middle;
            }
        }
        else
        {
            if (dState != DistanceState.Inactive)
            {
                DisableTextAndImage();
            }

            dState = DistanceState.Inactive;
        }

        if (dState == DistanceState.Active)
        {
            switch (sState)
            {
            case SubState.Writing:
                if (iLetter >= fileText[iParagraph].Length)
                {
                    sState = SubState.WaitingForNext;
                }
                else if (ControlManager.Instance.GetButtonDown("Submit"))
                {
                    iLetter = fileText[iParagraph].Length;
                    sState  = SubState.WaitingForNext;
                }
                else
                {
                    iLetter++;
                }

                break;

            case SubState.WaitingForNext:

                if (ControlManager.Instance.GetButtonDown("Submit"))
                {
                    NextDialogue();
                }

                break;

            case SubState.WaitingForReactivation:

                if (ControlManager.Instance.GetButtonDown("Submit"))
                {
                    RestartDialogue();
                }

                break;

            default:
                break;
            }
        }
    }
Ejemplo n.º 5
0
 internal void crearDistance(String p1, String p2)
 {
     ds = new DistanceState(p1, p2, 0, "DISTANCE");
 }