Exemplo n.º 1
0
    protected override void Start()
    {
        base.Start();
        rb2D = GetComponent <Rigidbody2D>();
        //defaultSpeed = moveSpeed;

        rdGO = Instantiate(ragdollRef, Vector3.zero, Quaternion.identity) as GameObject;

        rdCS         = rdGO.GetComponent <Enemy_Ragdoll>();
        rdTorsoRB    = rdGO.transform.Find("enemy1_deadBody_body").GetComponent <Rigidbody2D>();
        rdCS.soldier = gameObject;        //eSoldier;

        //rdHeadRB = rdGO.transform.Find ("head Transform").rigidbody2D;


        enemyA = GetComponent <Animator> ();

        headA   = transform.Find("head Transform").Find("head").GetComponent <Animator>();
        snipeCS = transform.Find("enemy1_deadBody_body").Find("enemy1_deadBody_armL").Find("enemy1_deadBody_handL").Find("sniperHand").GetComponent <SniperSight>();          //headA.transform.Find ("sniperEye").Find("eyeBeam").GetComponent<SniperSight>();
        //dickMouth = headA.transform.Find ("dickMouth").gameObject;


        GameObject eDamageGO = (GameObject)Instantiate(eDamageGOref, transform.position, Quaternion.identity);        //separate object needed so enemy_damage script coroutines keep working when going back and forth between enemy and ragdoll

        eDamage         = eDamageGO.GetComponent <Enemy_Damage> ();
        eDamage.enemyCS = this;

        eDamageT = transform.Find("enemy1_deadBody_body").Find("damage");
        eDamage.AwakeAfter(eDamageT);

        rdCS.eDamage  = eDamage;       //ragdoll CS references to eDamage
        rdCS.eDamageT = eDamageT;
        rdCS.LateAwake();

        SortSprites();
        rdGO.SetActive(false);


        //slightly random z depth
        Vector3 pos = transform.position;

        pos.z = Random.Range(2f, 0f);
        transform.position = pos;

        //StartCoroutine("SortSprites");

        if (equipped == Equipped.C4)
        {
            transform.Find("enemy1_deadBody_body").Find("c4").gameObject.SetActive(true);
            defaultSpeed = 13;
            if (!paratrooperMode)
            {
                moveSpeed = defaultSpeed;
            }
        }
        else if (equipped == Equipped.SHIELD)
        {
            transform.Find("enemy1_deadBody_body").Find("shield").gameObject.SetActive(true);
        }
        else if (equipped == Equipped.SNIPER)
        {
            //print ("YAYAYA");
            snipeCS.gameObject.SetActive(true);
            //if(!paratrooperMode){
            //status = eStatus.SHOOTING;
            if (!paratrooperMode)
            {
                enemyA.Play("enemySnipe");
                snipeCS.StartSniping();
            }
            //
            if (snipeWalk)
            {
                InvokeRepeating("switchSnipeWalk", 1, 5);
            }
            //}
            rdGO.transform.Find("enemy1_deadBody_handL").Find("sniperHand").gameObject.SetActive(true);
        }



        if (!facingRight && transform.localScale.x > 0)        //enemy placed in level, supposed to be facing left??
        {
            Flip();
            facingRight = false;
        }


        Level.enemyCount++;        //for max spawn of whole level;



        frontCheck  = transform.Find("frontCheck");
        frontCheck2 = transform.Find("frontCheck2");

        int layerMsk2 = 1 << LayerMask.NameToLayer("Props");
        int layerMsk1 = 1 << LayerMask.NameToLayer("Ground");
        int layerMsk3 = 1 << LayerMask.NameToLayer("OneWayGround");
        int layerMsk4 = 1 << LayerMask.NameToLayer("GroundMotion");

        //int layerMsk5 = 1 << LayerMask.NameToLayer("Pickups");
        layerMsk = layerMsk1 | layerMsk2 | layerMsk3 | layerMsk4;
        //shootLayerMsk = layerMsk1 | layerMsk2 |  layerMsk3 | layerMsk4;
        groundCheck = transform.Find("groundCheck");
        //InvokeRepeating("TestShoot", 0f, 4f);


        //parachute shit
        if (paratrooperMode)
        {
            makeChute();
            parachuting = true;
            status      = eStatus.PARACHUTING;
            rdGO.SetActive(true);

            switchToRagdoll();

            //rdGO.transform.Rotate (Vector3.forward * 90);
            //rdCS.makeNormalHeavy();
            rdCS.StartCoroutine("openChute");
            rdCS.aliveSwitch = 5f;
            rdCS.AddTorqueAll(-10, 10);
        }
        if (status == eStatus.IDLE)
        {
            enemyA.Play("enemyIdle");
        }
        //print (facingRight+"     "+moveSpeed);
    }
Exemplo n.º 2
0
    protected override void Start()
    {
        base.Start ();
        rb2D = GetComponent<Rigidbody2D>();
        //defaultSpeed = moveSpeed;

        rdGO = Instantiate(ragdollRef, Vector3.zero, Quaternion.identity) as GameObject;

        rdCS = rdGO.GetComponent<Enemy_Ragdoll>();
        rdTorsoRB = rdGO.transform.Find ("enemy1_deadBody_body").GetComponent<Rigidbody2D>();
        rdCS.soldier = gameObject;//eSoldier;

        //rdHeadRB = rdGO.transform.Find ("head Transform").rigidbody2D;

        enemyA = GetComponent<Animator> ();

        headA= transform.Find ("head Transform").Find ("head").GetComponent<Animator>();
        snipeCS = transform.Find ("enemy1_deadBody_body").Find ("enemy1_deadBody_armL").Find("enemy1_deadBody_handL").Find ("sniperHand").GetComponent<SniperSight>();//headA.transform.Find ("sniperEye").Find("eyeBeam").GetComponent<SniperSight>();
        //dickMouth = headA.transform.Find ("dickMouth").gameObject;

        GameObject eDamageGO = (GameObject)Instantiate(eDamageGOref,transform.position , Quaternion.identity);//separate object needed so enemy_damage script coroutines keep working when going back and forth between enemy and ragdoll
        eDamage = eDamageGO.GetComponent<Enemy_Damage> ();
        eDamage.enemyCS = this;

        eDamageT = transform.Find ("enemy1_deadBody_body").Find ("damage");
        eDamage.AwakeAfter(eDamageT);

        rdCS.eDamage = eDamage;//ragdoll CS references to eDamage
        rdCS.eDamageT = eDamageT;
        rdCS.LateAwake();

        SortSprites();
        rdGO.SetActive(false);

        //slightly random z depth
        Vector3 pos = transform.position;
        pos.z = Random.Range (2f, 0f);
        transform.position = pos;

        //StartCoroutine("SortSprites");

        if(equipped == Equipped.C4){
            transform.Find ("enemy1_deadBody_body").Find ("c4").gameObject.SetActive(true);
            defaultSpeed = 13;
            if(!paratrooperMode){
                moveSpeed = defaultSpeed;
            }
        }else if(equipped == Equipped.SHIELD){
            transform.Find ("enemy1_deadBody_body").Find ("shield").gameObject.SetActive(true);
        }else if(equipped == Equipped.SNIPER){
            //print ("YAYAYA");
            snipeCS.gameObject.SetActive(true);
            //if(!paratrooperMode){
                //status = eStatus.SHOOTING;
            if(!paratrooperMode){
                enemyA.Play("enemySnipe");
                snipeCS.StartSniping();
            }
                    //
                if(snipeWalk){
                    InvokeRepeating("switchSnipeWalk",1,5);

                }
            //}
            rdGO.transform.Find("enemy1_deadBody_handL").Find ("sniperHand").gameObject.SetActive(true);
        }

        if(!facingRight && transform.localScale.x > 0){//enemy placed in level, supposed to be facing left??
            Flip();
            facingRight = false;
        }

        Level.enemyCount++;//for max spawn of whole level;

        frontCheck = transform.Find("frontCheck");
        frontCheck2 = transform.Find ("frontCheck2");

        int layerMsk2 = 1 << LayerMask.NameToLayer("Props");
        int layerMsk1 = 1 << LayerMask.NameToLayer("Ground");
        int layerMsk3 = 1 << LayerMask.NameToLayer("OneWayGround");
        int layerMsk4 = 1 << LayerMask.NameToLayer("GroundMotion");
        //int layerMsk5 = 1 << LayerMask.NameToLayer("Pickups");
        layerMsk = layerMsk1 | layerMsk2 | layerMsk3 | layerMsk4;
        //shootLayerMsk = layerMsk1 | layerMsk2 |  layerMsk3 | layerMsk4;
        groundCheck = transform.Find ("groundCheck");
        //InvokeRepeating("TestShoot", 0f, 4f);

        //parachute shit
        if(paratrooperMode){
            makeChute();
            parachuting = true;
            status = eStatus.PARACHUTING;
            rdGO.SetActive(true);

            switchToRagdoll();

            //rdGO.transform.Rotate (Vector3.forward * 90);
            //rdCS.makeNormalHeavy();
            rdCS.StartCoroutine("openChute");
            rdCS.aliveSwitch = 5f;
            rdCS.AddTorqueAll(-10,10);

        }
        if (status == eStatus.IDLE) {
            enemyA.Play("enemyIdle");
        }
        //print (facingRight+"     "+moveSpeed);
    }