Exemplo n.º 1
0
        private void TakeNextTurn(int movement)
        {
            ReadyForNextTurn = false;
            hasCooledDown    = false;

            TotalStep += movement;
            int newMapPosition = player.MapPosition + movement;

            // Have the train stop at station
            // See if we have a station
            for (int i = 1; i <= 4; i++)
            {
                int stationIndex = 6 * i - 1;
                if (stationIndex > player.MapPosition && stationIndex <= newMapPosition)
                {
                    newMapPosition = stationIndex;
                    movement       = newMapPosition - player.MapPosition;
                }
            }

            if (newMapPosition > circle.Count)
            {
                Loop++;
                newMapPosition = newMapPosition % circle.Count - 1;
            }

            while (movement > 0)
            {
                player.MapPosition += 1;

                // restart from 0 after finishing a loop
                if (player.MapPosition >= circle.Count)
                {
                    player.MapPosition = 0;
                }

                player.Destination.Enqueue(circle[player.MapPosition].transform.position);
                movement -= 1;
            }

            // Execute event on the block
            if (circle[newMapPosition].Events.Count > 0)
            {
                currentEvent = circle[newMapPosition].Events.Dequeue();
                if (currentEvent != null)
                {
                    currentEvent.Execute(player);
                }
            }

            Turn++;
        }
Exemplo n.º 2
0
        private void Start()
        {
            counter = 0;
            loop    = 0;
            // Parse out the blocks in the circle
            Block[] blocksUnderDirectory = circleMasterDirectory.GetComponentsInChildren <Block>();
            foreach (Block b in blocksUnderDirectory)
            {
                circle.Add(b);
            }

            TextAsset contentFile = Resources.Load <TextAsset>(filename);

            if (contentFile == null)
            {
                Debug.LogError("Content file not found");
            }
            List <string> lines = ParseLinesAndCleanup(contentFile.text);

            for (int i = 0; i < lines.Count; i++)
            {
                string line = lines[i];
                if (line.Length > 2 && line[0] == '[')
                {
                    // the line is a statement
                    // Parse out tag
                    string tag = line.Substring(1, line.IndexOf(']') - 1);

                    switch (tag)
                    {
                    case "Notif":
                        currentEvent = ParseNotificationEvent(line);
                        break;

                    case "Choice":
                        currentEvent = ParseChoiceEvent(line);
                        break;

                    case "Null":
                        currentEvent = null;
                        break;

                    case "MultiNotif":
                        currentEvent = ParseMultiNotificationEvent(line);
                        break;

                    default:
                        Debug.LogError("Error paring out input text file : invalid tag");
                        break;
                    }

                    while (counter >= circle.Count)
                    {
                        counter -= circle.Count;
                        loop++;
                    }
                    circle[counter].Events.Enqueue(currentEvent);
                    counter++;
                }
            }
        }