Esempio n. 1
0
    //Assets\stuff\Assets\anzug_glatze_sprite.png

    #region monobehaviour Stuff

    /// <summary>
    /// setting up the instructionManager, the user, spawns all entities and set the camera to follow player
    /// </summary>
    void Start()
    {
        currTime = 0;
        #region IntstructionManager
        IManager = new InstructionManager();
        //IManager.SaveInstructions (new InstructionMovement (2f, 0, new Vector2 (4f, 4f), 3));

        //InstructionData[] idat = new InstructionData[1];
        //idat [0] = new InstructionMovement (2f, 4, new Vector2 (3, 21), 5f);
        //IManager.SaveInstructions (idat);
        IManager.LoadInstructions();
        #endregion


        #region user

        List <InputMovement> input = new List <InputMovement> ();
        input.Add(new InputMovement(KeyCode.W, new Vector2(0f, 1f), PressTypes.KeyDownKey));
        input.Add(new InputMovement(KeyCode.S, new Vector2(0f, -1f), PressTypes.KeyDownKey));
        input.Add(new InputMovement(KeyCode.D, new Vector2(1f, 0f), PressTypes.KeyDownKey));
        input.Add(new InputMovement(KeyCode.A, new Vector2(-1f, 0f), PressTypes.KeyDownKey));

        GameObject player = new GameObject("Player", typeof(SpriteRenderer), typeof(CircleCollider2D), typeof(Rigidbody2D));

        player.GetComponent <Rigidbody2D> ().isKinematic  = true;
        player.GetComponent <Rigidbody2D> ().bodyType     = RigidbodyType2D.Dynamic;
        player.GetComponent <Rigidbody2D> ().mass         = 1;
        player.GetComponent <Rigidbody2D> ().drag         = 1000;
        player.GetComponent <Rigidbody2D> ().angularDrag  = 10;
        player.GetComponent <Rigidbody2D> ().gravityScale = 0;

        player.GetComponent <CircleCollider2D> ().radius = 1.5f;
        player.GetComponent <SpriteRenderer> ().sprite   = CharacterSprites [0];

        AddNewPlayer(player, input);
        //Instantiate(player);
        Debug.Log("object created");
        #endregion

        new Spawner(this);

        //kann benutzt werden um slowmos zu machen und so
        //einfach Zeitlauf verlangsamen
        //Debug.Log (Time.timeScale);
        Camera.main.gameObject.GetComponent <Camera_Behaivour> ().target = entities [0].entity.transform;
    }