Пример #1
0
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        // scene 0 ~ 2 level number is -1 0 1, later unchange
        // scene 2~4 sublevel 1 2 3
        if (scene.buildIndex >= 2)
        {
            level    = 1;
            subLevel = scene.buildIndex - 1;

            // assign player position
            GameObject p = GameObject.FindGameObjectWithTag("Player");
            player       = p.transform;
            playerScript = p.GetComponent <UnityStandardAssets._2D.PlatformerCharacter2D>();
            userCtrl     = p.GetComponent <UnityStandardAssets._2D.Platformer2DUserControl>();

            findNotificationManager();
            ladderManager = GameObject.Find("TrapDoorTriggers").GetComponent <LadderManager>();

            if (startFromLoad)
            {
                SetupFromLoad();
                startFromLoad = false;
            }

            InitGame();
        }
        else
        {
            level = -1;
        }
    }
Пример #2
0
        private void getItem(GameObject player)
        {
            /* ITEM DROP TABLE
             * ITEM_CODE    ITEM_NAME           DROPRATE
             * Item1        Black Hole          25%
             * Item2        Holy Hand Grenade   25%
             * Item3        Buns                25%         //Note: Bun is referred to as SyringeNeedle in the code
             * Item4        Rocket Barrage      25%
             */
            float  roll = Random.value;
            string item = "";

            if (roll <= 0.25)
            {
                item = "Item1";
            }                                    //item1
            else if (roll <= 0.5)
            {
                item = "Item2";
            }                                        //item2
            else if (roll <= 0.75)
            {
                item = "Item3";
            }                                         //item3
            else if (roll <= 1)
            {
                item = "Item4";
            }                                      //item4
            print("Got " + item);

            Platformer2DUserControl playerCtrl = player.GetComponent <Platformer2DUserControl>();

            playerCtrl.setItem(item); //update the item variable on the other script
        }
 private void Awake()
 {
     // Setting up references.
     m_GroundCheck  = transform.Find("GroundCheck");
     m_CeilingCheck = transform.Find("CeilingCheck");
     m_Anim         = GetComponent <Animator>();
     m_Rigidbody2D  = GetComponent <Rigidbody2D>();
     playerCon      = GetComponent <Platformer2DUserControl>();
 }
Пример #4
0
	void Start()
	{
		// Should only be one
		_convoPlayer = FindObjectOfType<ConversationPlayer>();

		if ( _convoPlayer != null )
			_convoPlayer._conversationEnd.AddListener( () => OnConversationEnd() );

		_controls = GetComponent<UnityStandardAssets._2D.Platformer2DUserControl>();
	}
Пример #5
0
        // Use this for initialization
        void Start()
        {
            m_GetRigidbody = GetComponent <Rigidbody2D>();
            m_Player       = FindObjectOfType <Platformer2DUserControl>();

            if (m_Player.transform.localScale.x < 0)
            {
                speed = -speed;
            }
        }
 // Start is called before the first frame update
 void Start()
 {
     totstates     = NrOfFeatures * NrOfFeatures;
     playerinfo    = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <HUDscript>();
     playercontrol = GetComponent <Platformer2DUserControl>();
     mychar        = GetComponent <PlatformerCharacter2D>();
     CreatenewAgent();
     //curr_agent = this;
     testint    = 0;
     hasbeenhit = false;
     realplayer = GameObject.FindGameObjectWithTag("Player");
     myagents   = new List <Agent>();
     canjump    = true;
     //Mathf.Pow(NrOfFeatures, 2);
 }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType <UnityStandardAssets._2D.Platformer2DUserControl>();

        m_MainCamera = Camera.main;
        birb         = GameObject.Find("Birb");
        foxr         = GameObject.Find("Foxr");
        foxr.SetActive(false);
        posun = GameObject.Find("Posun");
        posun.SetActive(false);
        Time.timeScale  = 0;
        StartText       = GameObject.Find("PressStart").GetComponent <Image>();
        PauseMenu       = GameObject.Find("C-change-character");
        PauseQuit       = GameObject.Find("P-pause--start");
        m_MyAudioSource = GetComponent <AudioSource>();
    }
Пример #8
0
        // Use this for initialization
        void Start()
        {
            player         = gameObject;
            ctrl           = gameObject.GetComponent <Platformer2DUserControl>();
            difficulty     = 4;
            num1           = generateRandomOperand();
            num2           = generateRandomOperand();
            ans            = num1 * num2;
            challenge.text = num1 + "x" + num2;

            if (isLocalPlayer)
            {
                return;
            }

            cam.enabled  = false;
            ctrl.enabled = false;
        }
Пример #9
0
    // Start is called before the first frame update
    void Start()
    {
        rb2d           = GetComponent <Rigidbody2D>();
        spriteRenderer = GetComponent <SpriteRenderer>();
        boxCollider    = GetComponent <BoxCollider2D>();
        playerInput    = GameObject.Find("Player").GetComponent <UnityStandardAssets._2D.Platformer2DUserControl>();
        worldStatus    = GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <WorldStatus>();

        //Campfire Sit Collider disappears after the forest gets color
        if (type == "Campfire" && worldStatus.ForestBackground)
        {
            active = false;
        }
        if (type == "NightSky" && worldStatus.stars == true)
        {
            active = false;
            spriteRenderer.enabled = true;
        }
    }
Пример #10
0
    public int difficultyLevel; //difficulty level for when PCG disabled //Levels: 0 = easy, 1 = normal, 2 = hard

    // Use this for initialization
    void Awake ()
    {
        //platforms = new Queue<GameObject>();
        platforms = new LinkedList<GameObject>();
        overheadPlatforms = new LinkedList<GameObject>();
        platformTime = 2.0f;
        speedTimer = 0.0f;
        score = 0;
        startPlatform.GetComponent<Platform>().setSize(8);
        Debug.Log("SIZE SET: "+ startPlatform.GetComponent<Platform>().getSize());
        //add starting platform
        platforms.AddLast(startPlatform);
        //get difficulty level if PCG mode is off
        if (!isPCG_On)
        {
            difficultyLevel = PlayerPrefs.GetInt(SaveManager.difficultyLevel);
        }
        else
        {
            difficultyLevel = 1;
        }
        //add a few platforms to act as a buffer
        createDifficultyPlatform();
        createDifficultyPlatform();
        createDifficultyPlatform();
        //PEM
        gameTime = 0;
        playerScript = player.GetComponent<UnityStandardAssets._2D.Platformer2DUserControl>();
        currentAverageSpeed = 0;
        distanceToStart = 0;
        previousDistance = 0;
        platformGap = 5;

        
        gameSpeed = 0.01f;
        deathScene.SetActive(false);
    }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        currentScene = SceneManager.GetActiveScene();
        if (Time.timeScale == 1 && !player.GetComponent <Renderer>().isVisible)
        {
            player.birbDead = 1;
        }

        if (player.birbDead == 1 || PlayerPrefs.GetInt("dead") == 1)
        {
            PlayerPrefs.SetInt("score", count);
            PlayerPrefs.SetInt("dead", 0);
            SceneManager.LoadScene("death");
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            player.birbDead = 0;
            RespawnBirb();
            SceneManager.LoadScene("mainmenu");
        }

        if (Input.GetKeyDown(KeyCode.C) && (currentScene.name == "first" || currentScene.name == "sec" || currentScene.name == "third"))
        {
            if (birb.activeSelf == true)
            {
                birb.SetActive(false);
                foxr.SetActive(true);
            }
            else if (foxr.activeSelf == true)
            {
                foxr.SetActive(false);
                posun.SetActive(true);
            }
            else if (posun.activeSelf == true)
            {
                posun.SetActive(false);
                birb.SetActive(true);
            }

            player = FindObjectOfType <UnityStandardAssets._2D.Platformer2DUserControl>();
        }

        if (Input.GetKeyDown(KeyCode.P) && (currentScene.name == "first" || currentScene.name == "sec" || currentScene.name == "third"))
        {
            player = FindObjectOfType <UnityStandardAssets._2D.Platformer2DUserControl>();
            if (Time.timeScale == 0)
            {
                StartText.enabled = false;
                PauseMenu.SetActive(false);
                PauseQuit.SetActive(false);
                Time.timeScale = 1;
                m_MyAudioSource.Play();
            }
            else
            {
                Time.timeScale    = 0;
                StartText.enabled = true;
                PauseMenu.SetActive(true);
                PauseQuit.SetActive(true);
                m_MyAudioSource.Pause();
            }
        }
    }
Пример #12
0
 // Use this for initialization
 void Awake()
 {
     rb             = GetComponent <Rigidbody2D>();
     timeLeftToTrip = 0;
     control        = GetComponent <UnityStandardAssets._2D.Platformer2DUserControl>();
 }
Пример #13
0
 private void Awake()
 {
     // Grab ref to player character
     m_Character = GetComponent <Platformer2DUserControl>();
 }