예제 #1
0
    void Start()
    {
        if (null != game_controller.instance)
        {
            Destroy(this);
            return;
        }

        game_controller.instance = this;
    }
예제 #2
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != null)
     {
         Destroy(gameObject);
     }
 }
    // Start is called before the first frame update
    void Start()
    {
        gameController  = GameObject.FindGameObjectWithTag("GameController").GetComponent <game_controller>();
        transform       = GetComponent <Transform>();
        meshRenderer    = GetComponentInChildren <MeshRenderer>();
        boundry         = GameObject.FindGameObjectWithTag("boundry");
        boundryCollider = boundry.GetComponent <EdgeCollider2D>();
        headSize        = head.GetComponent <Renderer>().bounds.size.x;

        // Spawn initial body
        playerBodySections.Add(head);
        for (int i = 0; i < startingSize; i++)
        {
            spawnNewBodySection();
        }

        isAlive = true;
    }
예제 #4
0
    public int home_pos   = 0; //max 1

    void Start()
    {
        // Finds the game controller script attached to the object in the hierarchy
        game_ = GameObject.Find("game_controller").GetComponent <game_controller>();
    }
예제 #5
0
 // Use this for initialization
 void Start()
 {
     // Initialise scripts by finding the game objects they are attached to in the hierarchy
     game_ = GameObject.Find("game_controller").GetComponent <game_controller>();
     end_  = GameObject.Find("end_check").GetComponent <end_check_>();
 }
예제 #6
0
 // Ensure that the instance is destroyed when the game is stopped in the editor.
 void OnApplicationQuit()
 {
     s_Instance = null;
 }
예제 #7
0
    public override void OnInspectorGUI()
    {
        game_controller myTarget = (game_controller)target;

        // Prefabs objects
        showPrefab = EditorGUILayout.Foldout(showPrefab, "Prefabs objects");
        if (showPrefab)
        {
            EditorGUI.indentLevel = 2;

            // Player Prefab
            GameObject pObj = (GameObject)EditorGUILayout.ObjectField("Player Prefab", myTarget.playerPrefab, typeof(Object), true);
            if (pObj != null && PrefabUtility.GetPrefabType(pObj) == PrefabType.Prefab)
            {
                myTarget.playerPrefab = pObj;
            }
            else
            {
                myTarget.playerPrefab = null;
            }

            // Ball Prefab
            GameObject bObj = (GameObject)EditorGUILayout.ObjectField("Ball Prefab", myTarget.ballPrefab, typeof(Object), true);
            if (bObj != null && PrefabUtility.GetPrefabType(bObj) == PrefabType.Prefab)
            {
                myTarget.ballPrefab = bObj;
            }
            else
            {
                myTarget.ballPrefab = null;
            }

            // Player Field
            myTarget.game_variables.PlayerField = (GameObject)EditorGUILayout.ObjectField("Player Field", myTarget.game_variables.PlayerField, typeof(Object), true);
        }

        // Left Player variables
        EditorGUI.indentLevel = 0;
        showLeftPlayer        = EditorGUILayout.Foldout(showLeftPlayer, "Left player configurations");
        if (showLeftPlayer)
        {
            EditorGUI.indentLevel = 2;

            // Color
            myTarget.game_variables.LeftPlayer_Color = EditorGUILayout.ColorField("Player Color", myTarget.game_variables.LeftPlayer_Color);

            // Keys
            myTarget.game_variables.LeftPlayer_UpKey    = (KeyCode)EditorGUILayout.EnumPopup("Up Key", myTarget.game_variables.LeftPlayer_UpKey);
            myTarget.game_variables.LeftPlayer_DownKey  = (KeyCode)EditorGUILayout.EnumPopup("Down Key", myTarget.game_variables.LeftPlayer_DownKey);
            myTarget.game_variables.LeftPlayer_LeftKey  = (KeyCode)EditorGUILayout.EnumPopup("Left Key", myTarget.game_variables.LeftPlayer_LeftKey);
            myTarget.game_variables.LeftPlayer_RightKey = (KeyCode)EditorGUILayout.EnumPopup("Right Key", myTarget.game_variables.LeftPlayer_RightKey);

            //Powers
        }

        EditorGUI.indentLevel = 0;
        showRightPlayer       = EditorGUILayout.Foldout(showRightPlayer, "Right player configurations");
        if (showRightPlayer)
        {
            EditorGUI.indentLevel = 2;

            // Color
            myTarget.game_variables.RightPlayer_Color = EditorGUILayout.ColorField("Player Color", myTarget.game_variables.RightPlayer_Color);

            // Keys
            myTarget.game_variables.RightPlayer_UpKey    = (KeyCode)EditorGUILayout.EnumPopup("Up Key", myTarget.game_variables.RightPlayer_UpKey);
            myTarget.game_variables.RightPlayer_DownKey  = (KeyCode)EditorGUILayout.EnumPopup("Down Key", myTarget.game_variables.RightPlayer_DownKey);
            myTarget.game_variables.RightPlayer_LeftKey  = (KeyCode)EditorGUILayout.EnumPopup("Left Key", myTarget.game_variables.RightPlayer_LeftKey);
            myTarget.game_variables.RightPlayer_RightKey = (KeyCode)EditorGUILayout.EnumPopup("Right Key", myTarget.game_variables.RightPlayer_RightKey);
        }

        // In-game variables
        EditorGUI.indentLevel = 0;
        showInGameVars        = EditorGUILayout.Foldout(showPrefab, "In-game variables");
        if (showInGameVars)
        {
            EditorGUI.indentLevel = 2;

            // Gamebjects
            GUI.enabled = false;
            EditorGUILayout.ObjectField("Left Player", myTarget.game_variables.LeftPlayer, typeof(Object), true);
            EditorGUILayout.ObjectField("Right Player", myTarget.game_variables.RightPlayer, typeof(Object), true);
            EditorGUILayout.ObjectField("Ball", myTarget.game_variables.Ball, typeof(Object), true);
            GUI.enabled = true;

            // Player Score
            GUI.enabled = false;
            EditorGUILayout.IntField("Left player score", myTarget.game_variables.LeftPlayerScore);
            EditorGUILayout.IntField("Right player score", myTarget.game_variables.RightPlayerScore);
            GUI.enabled = true;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty((game_controller)target);
        }
    }
예제 #8
0
 // Use this for initialization
 void Start()
 {
     g_controller = GetComponent<game_controller>();
     total_points = 0;
 }