Exemplo n.º 1
0
 void MakeInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Exemplo n.º 2
0
    public void Setup()
    {
#if UNITY_EDITOR
        var bridgeGO = GameObject.Find(BridgeScript.bridgeGameObjectName);
        if (bridgeGO == null)
        {
            bridgeGO = new GameObject(BridgeScript.bridgeGameObjectName, typeof(BridgeScript));

            DeleteAssetsIfExist();

            var spawningBase_PlayerPrefab = new GameObject("SpawningBase_PlayerPrefab");
            spawningBase_PlayerPrefab.AddComponent <SpawningBase_PlayerScript>();
            PrefabUtility.SaveAsPrefabAsset(spawningBase_PlayerPrefab, "Assets/" + spawningBase_PlayerPrefab.name + ".prefab");
            GameObject.DestroyImmediate(spawningBase_PlayerPrefab);

            var spawningBase_SpawnableObjectPrefab = new GameObject("SpawningBase_SpawnableObjectPrefab");
            spawningBase_SpawnableObjectPrefab.AddComponent <SpawningBase_SpawnableObjectScript>();
            PrefabUtility.SaveAsPrefabAsset(spawningBase_SpawnableObjectPrefab, "Assets/" + spawningBase_SpawnableObjectPrefab.name + ".prefab");
            GameObject.DestroyImmediate(spawningBase_SpawnableObjectPrefab);

            m_BridgeScript = bridgeGO.GetComponent <BridgeScript>();
            m_BridgeScript.playerPrefab = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/SpawningBase_PlayerPrefab.prefab");
            m_BridgeScript.rocketPrefab = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/SpawningBase_SpawnableObjectPrefab.prefab");
        }
#endif
    }
Exemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject InputControllerManagerObject = GameObject.Find("InputController");

        inputControllerScript = InputControllerManagerObject.GetComponent <InputControllerScript>();

        SelectedObject = inputControllerScript.GetSelectedObject();

        GameObject Canvas = GameObject.Find("GUI");
        GameObject GUIEventSystemObject = GameObject.Find("EventSystem");

        Raycaster   = Canvas.GetComponent <GraphicRaycaster>();
        eventSystem = GUIEventSystemObject.GetComponent <EventSystem>();

        PolygonCollider = gameObject.GetComponent <PolygonCollider2D>();


        //Find the controller for the selected object
        if (SelectedObject.tag == "Node")
        {
            nodeScript = SelectedObject.GetComponent <NodeScript>();
        }
        else if (SelectedObject.tag == "BridgePiece")
        {
            bridgeScript = SelectedObject.GetComponent <BridgeScript>();
        }
        else
        {
            // Debug.Log("Unrecognized selection!");
            Destroy(gameObject);
        }
    }
Exemplo n.º 4
0
    void Start()
    {
        // Add listeners for onClick
        button.onClick.AddListener(delegate { OnClick(); });
        bridgeObjects = GameObject.FindGameObjectsWithTag("bridge");
        bridges       = new BridgeScript[bridgeObjects.Length];
        int n = 0;

        foreach (GameObject brid in bridgeObjects)
        {
            BridgeScript bridge = brid.GetComponent(typeof(BridgeScript)) as BridgeScript;
            bridges[n] = bridge;
            n++;
        }
    }
Exemplo n.º 5
0
    private void FloodRiver()
    {
        if ((Time.time >= nextFlood - 120))
        {
            rain.RainIntensity = 1;
        }

        if ((Time.time >= nextFlood - 60))
        {
            rain.RainIntensity = 2;
        }

        if ((Time.time >= nextFlood - 30))
        {
            rain.RainIntensity = 3;
            if (!floodBeforeWritten)
            {
                agentManager.GetComponent <AgentsCountersTxtboxesUpdater>().WriteLogBeforeFlood();
                floodBeforeWritten = true;
            }
        }

        if ((Time.time >= nextFlood - 15))
        {
            rain.RainIntensity = 5;
        }

        if ((Time.time >= nextFlood - 5))
        {
            rain.RainIntensity = 7;
        }


        if ((Time.time >= nextFlood))
        {
            nextFlood = Mathf.FloorToInt(Time.time) + FLOOD_TIMER - (timesInvoked * 5);
            animation.startAnimation();

            for (int i = 0; i < agentManager.transform.GetChildCount(); i++)
            {
                if (isAgentOnRiver(agentManager.transform.GetChild(i).transform.position))
                {
                    agentManager.transform.GetChild(i).GetComponent <AgentActionsSelector>().GotDrowned();
                }
            }

            for (int i = 0; i < transform.childCount; i++)
            {
                BridgeScript bridgeScript = transform.GetChild(i).GetComponent("BridgeScript") as BridgeScript;
                if (bridgeScript != null)
                {
                    bridgeScript.Destroy();
                }
            }
            timesInvoked++;

            if (timesInvoked == 5)
            {
                nextFlood = Mathf.FloorToInt(Time.time) + FLOOD_TIMER;
            }


            if ((Time.time + 30 >= (nextFlood - FLOOD_TIMER)))
            {
                if (!floodAfterWritten)
                {
                    agentManager.GetComponent <AgentsCountersTxtboxesUpdater>().WriteLogAfterFlood();
                    floodAfterWritten = true;
                }
            }


            rain.RainIntensity = 0;
        }
    }
 private void Start()
 {
     //We need to find the BridgeScript to be able to use it in our Function
     bridgeScript = GameObject.Find("Bridge").GetComponent <BridgeScript>();
 }