// Use this for initialization
 void Start()
 {
     //Initializes the players RigidBody, Animator and EnemyScript
     rb2d        = GetComponent <Rigidbody2D>();
     animator    = GetComponent <Animator>();
     enemyScript = enemy.GetComponent <MergedPlayerBehaviour>();
 }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     P1Script = PlayerOne.GetComponent <MergedPlayerBehaviour>();
     P2Script = PlayerTwo.GetComponent <MergedPlayerBehaviour>();
     P2Script.setOnRightSide(false);
     P1Script.setOnRightSide(true);
 }
    // Use this for initialization
    void Start()
    {
        //Initializes the players RigidBody, Animator and EnemyScript
        rb2d        = GetComponent <Rigidbody2D>();
        animator    = GetComponent <Animator>();
        enemyScript = enemy.GetComponent <MergedPlayerBehaviour>();

        int character = 2; //Default character

        if (gameObject.tag == "Player1")
        {
            character = DataStore.PlayerOneCharacter;
            if (DataStore.p1Controls != null)
            {
                this.controls = DataStore.p1Controls;
            }
        }
        else
        {
            character = DataStore.PlayerTwoCharacter;
            if (DataStore.p2Controls != null)
            {
                this.controls = DataStore.p2Controls;
            }
        }

        Debug.Log(gameObject.name + " has selected " + character);
        if (character == 1)
        {
            this.dashLength   = 0.15f;
            this.dashCooldown = 0.75f;
            this.jumpSpeed    = 25;
            this.attackRange  = 1;
            this.maxBlockDur  = 1.5f;
            this.blockCD      = 1.2f;
            this.playerSpeed  = 7;
            doubleJump        = true;
            GetComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animations/Samurai/ata1");
            SpriteRenderer renderer = GetComponent <SpriteRenderer>();
            renderer.flipX = !renderer.flipX;
        }
        else if (character == 3)
        {
            this.dashLength   = 0.17f;
            this.dashCooldown = 1.1f;
            this.jumpSpeed    = 32;
            this.attackRange  = 2;
            this.maxBlockDur  = 0.8f;
            this.blockCD      = 1.0f;
            this.playerSpeed  = 11;
            GetComponent <Animator>().runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animations/Munk/Munk");
            SpriteRenderer renderer = GetComponent <SpriteRenderer>();
            renderer.flipX = !renderer.flipX;
        }
        else
        {
            //Nothing, you are the default
        }

        if (DataStore.controller1 && gameObject.tag == "Player1")
        {
            this.controls = Resources.Load <Controls>("Player1PS3Controller");
        }
        else if (DataStore.controller2 && gameObject.tag == "Player2")
        {
            this.controls = Resources.Load <Controls>("Player2PS3Controller");
        }

        //initialise the sound sources
        AudioSource[] sounds = GetComponents <AudioSource>();
        if (sounds != null)
        {
            jumpSound        = sounds[0];
            jabSound         = sounds[1];
            groundPoundSound = sounds[2];
            dashSound        = sounds[3];
            gameOverSound    = sounds[4];
        }
        GameObject obj = GameObject.Find("FightMusic");

        if (obj != null)
        {
            this.fightMusic = obj.GetComponent <AudioSource>();
        }
    }