Example #1
0
 private void Awake()
 {
     currWave           = startWave;
     enemyList          = new List <Enemy>();
     frontGateStartPos  = frontGate.position;
     frontGateTrigger   = frontGate.GetComponentInChildren <GateTrigger>();
     secondGateStartPos = secondGate.position;
     secondGateTrigger  = secondGate.GetComponentInChildren <GateTrigger>();
     bossGate.OnBreak  += OnBossGateBreak;
 }
Example #2
0
 // when lap trigger is entered
 public void OnLapTrigger(GateTrigger trigger)
 {
     if (trigger == nextLapTrigger)
     {
         if (currentLapTrigger == nextLapTrigger)
         {
             _lap++;
             saveLapTimeData();
             UpdateText();
             winner();
         }
         SetNextTrigger(nextLapTrigger);
     }
 }
Example #3
0
    void DoGatesInOrder(GateTrigger trigger)
    {
        if (!complete)
        {
            //check which gate was triggered

            if (gates.Contains(trigger))
            {
                int index = currentList.IndexOf(trigger);
                //if the start index has not been set
                if (!inProgress)
                {
                    Debug.Log("Puzzle started at index " + index);

                    Debug.Log("Gate " + index + " hit");

                    UpdateList(index); //re-order the list around the new starting index
                    Debug.Log("Current list: " + PrintGateList());
                    trigger.PlayAudioClip(AssetManager.instance.gateTones[currentIndex]);
                    inProgress = true;

                    StartTimer();
                }
                else
                {
                    //if the player is touching the gates in order, increment
                    Debug.Log("Gate " + index + " hit");
                    currentIndex++;

                    if (index == currentIndex)
                    {
                        trigger.PlayAudioClip(AssetManager.instance.gateTones[currentIndex]);
                        Debug.Log("Index " + index + " Current Index " + currentIndex + " Gate Length " + (currentList.Count - 1));
                        if (index == currentList.Count - 1)
                        {
                            Debug.Log("Complete!");
                            CompletePuzzle();
                        }
                    }
                    else
                    {
                        //if this gate was triggered in the wrong order, reset the puzzle
                        trigger.PlayAudioClip(AssetManager.instance.gateTones[6]);
                        ResetPuzzle();
                    }
                }
            }
        }
    }
Example #4
0
    public override void GateTriggered(GateTrigger trigger)
    {
        //check if we only have one gate
        if (gates.Count == 1)
        {
            CompletePuzzle();
        }

        if (inOrder)
        {
            DoGatesInOrder(trigger);
        }
        else
        {
            DoGatesOutOfOrder(trigger);
        }
    }
Example #5
0
    public override void GateTriggered(GateTrigger trigger)
    {
        if (complete)
        {
            return;
        }

        //deactivate this gate and spawn a new one
        Destroy(trigger.gameObject);
        if (currentGate < gateCount)
        {
            SpawnGate();
            currentGate++;
        }
        if (currentGate == gateCount)
        {
            Debug.Log("Puzzle complete!");
            complete = true;
            DeleteForcefield();
        }
    }
Example #6
0
    void DoGatesOutOfOrder(GateTrigger trigger)
    {
        if (!complete)
        {
            //check which gate was triggered

            if (gates.Contains(trigger))
            {
                int index = currentList.IndexOf(trigger);
                //if the start index has not been set
                if (!inProgress)
                {
                    Debug.Log("Puzzle started at index " + index);
                    Debug.Log("Gate " + index + " hit");


                    trigger.PlayAudioClip(AssetManager.instance.gateTones[currentIndex]);
                    inProgress = true;
                    gatesHit++;
                    Debug.Log(gates.Count - gatesHit + " gates left!");
                    StartTimer();
                }
                else
                {
                    //if the player touched another gate, update accordingly
                    Debug.Log("Gate " + index + " hit");
                    gatesHit++;
                    Debug.Log(gates.Count - gatesHit + " gates left!");
                    trigger.PlayAudioClip(AssetManager.instance.gateTones[currentIndex]);
                    if (gatesHit == currentList.Count)
                    {
                        CompletePuzzle();
                    }
                }
            }
        }
    }
Example #7
0
 // Use this for initialization
 void Start()
 {
     gatescript   = GetComponent <GateTrigger>();
     buttonscript = GetComponent <GateTrigger>();
 }
Example #8
0
 public virtual void GateTriggered(GateTrigger trigger)
 {
 }
Example #9
0
    //adding the next lap trigger counter into
    void SetNextTrigger(GateTrigger trigger)
    {
        nextLapTrigger = trigger.next;

        //Debug.Log("next=" + nextLapTrigger.gameObject.name);
    }
Example #10
0
    public static bool BuildLevel(Map mapToBuild, Transform parent)
    {
        GameObject[,] objectMap = new GameObject[Map.MapSize[0], Map.MapSize[1]]; // For establishing object links
        Dictionary <int[], int[]> linkStorage = new Dictionary <int[], int[]>();  // Store link information from map
        List <Enemy> generatedEnemies         = new List <Enemy>();               // Store enemies for player script
        Player       playerScript             = null;
        Finish       endScript = null;

        try
        {
            for (int x = 0; x < Map.MapSize[0]; x++)
            {
                for (int y = 0; y < Map.MapSize[1]; y++)
                {
                    Cell       cellToBuild = mapToBuild.GetCell(x, y);
                    GameObject builtObject = CreateObject(x, y, cellToBuild, parent);
                    if (cellToBuild.ObjectType == ObjectTypes.Enemy)
                    {
                        generatedEnemies.Add(builtObject.GetComponent <Enemy>());
                        switch (cellToBuild.Direction)
                        {
                        case 0:
                            builtObject.GetComponent <Enemy>().currentDirection = Direction.Right;
                            break;

                        case 1:
                            builtObject.GetComponent <Enemy>().currentDirection = Direction.Down;
                            break;

                        case 2:
                            builtObject.GetComponent <Enemy>().currentDirection = Direction.Left;
                            break;

                        case 3:
                        default:
                            builtObject.GetComponent <Enemy>().currentDirection = Direction.Up;
                            break;
                        }
                    }
                    else if (cellToBuild.ObjectType == ObjectTypes.Player)
                    {
                        playerScript               = builtObject.GetComponent <Player>();
                        playerScript.lifeLine      = GameObject.Find("Game Manager").GetComponent <LifeController>();
                        playerScript.startPosition = new Vector3(x, 1.5f, y);                         // Same as player objectY from CreateObject()
                    }
                    else if (cellToBuild.ObjectType == ObjectTypes.End)
                    {
                        endScript             = builtObject.GetComponent <Finish>();
                        endScript.nextButton  = panelNextButton;
                        endScript.retryButton = retryButton;
                    }
                    objectMap[x, y] = builtObject;
                    List <int[]> objectLinks = cellToBuild.Link;                    // Store link to link after all objects are built
                    foreach (int[] objectLink in objectLinks)
                    {
                        if (objectLink[0] >= 0 && objectLink[1] >= 0)
                        {
                            Debug.Log(linkStorage.Count);
                            linkStorage.Add(new int[] { x, y }, new int[] { objectLink[0], objectLink[1] }); // Save coords of linked objects
                        }
                    }
                }
            }
            Debug.Log(linkStorage.Count);
            foreach (KeyValuePair <int[], int[]> link in linkStorage)           // Link triggers and gates
            {
                Debug.Log("Entered kvp loop");
                GameObject linkSource      = objectMap[link.Key[0], link.Key[1]];     // Get source object
                GameObject linkDestination = objectMap[link.Value[0], link.Value[1]]; // Get linked object
                Debug.Log(linkSource);
                GateTrigger gateSource = linkSource.GetComponent <GateTrigger>();     // Check if source object is a gate
                if (gateSource == null)                                               // If not gate then next cell
                {
                    Debug.Log("Iteration skipped");
                    continue;
                }
                gateSource.Link.Add(linkDestination);                 // Set object to disable by trigger
            }
            if (playerScript != null)
            {
                playerScript.enemyList = generatedEnemies;
                foreach (Enemy enemyScript in generatedEnemies)
                {
                    enemyScript.player = playerScript;
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log("Level build failed: " + e.Message);
            return(false);
        }
        return(true);
    }
Example #11
0
 private void Awake()
 {
     gate_trigger = gameObject.GetComponentInParent <GateTrigger>();
 }