Esempio n. 1
0
 void Awake()
 {
     //  Find and assign references
     charController        = GetComponent <CharacterController>();
     playerController      = GetComponent <PlayerController>();
     animator              = GetComponent <Animator>();
     puppet2DGlobalControl = GetComponentInChildren <Puppet2D_GlobalControl>();
 }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     globalControl = GetComponent <Puppet2D_GlobalControl> ();
     animator      = GetComponent <Animator> ();
     //gunTop = transform.Find ("gunTop");
     stepManager    = GameObject.FindObjectOfType <StepManager> ();
     originPosition = transform.position;
     Debug.Log("originPosition" + originPosition);
     Debug.Log("originPosition.local" + transform.localPosition);
 }
Esempio n. 3
0
 void Awake()
 {
     //  Find and assign references
     charController        = GetComponent <CharacterController>();
     playerCollisions      = GetComponent <PlayerCollisions>();
     animator              = GetComponent <Animator>();
     puppet2DGlobalControl = GetComponentInChildren <Puppet2D_GlobalControl>();
     //rigidBody = GetComponent<Rigidbody>();
     //capCollider = GetComponent<CapsuleCollider>();
 }
Esempio n. 4
0
	// Use this for initialization
	void Start () {
		audioSFX = GetComponents<AudioSource> ();
		jumpTimeCheck = 0;
		lastColliders = new List<Collider2D> ();
		thisParent = transform.parent.gameObject;
		leftBottomScreen = Camera.main.ScreenToWorldPoint (new Vector2 (0, 0));
		rightTopScreen = Camera.main.ScreenToWorldPoint (new Vector2 (Screen.width, Screen.height));

		prevScreenWidth = Screen.width;

		thisBody = GetComponent<Rigidbody2D> ();
		thisCollider = GetComponent<Collider2D> ();

		canJump = 0;

		baseParent = transform.parent;

		movSpeedX = 0;
		movSpeedY = 0;

		state = "normal";

		arrow = transform.GetChild(1).Find ("arrow").gameObject;
		rock = transform.GetChild(1).Find ("rock").gameObject;
		explosion = transform.GetChild (1).Find ("fireExplosion").gameObject;

		characterAnimScript = transform.GetChild (1).GetComponent<Puppet2D_GlobalControl> ();
		characterAnimator = transform.GetChild (1).GetComponent<Animator> ();

		ropeAnimator = transform.GetChild (2).GetComponent<Animator> ();

		if (globalScript.previousScene != "") {
			GameObject spawnPoints = GameObject.Find ("spawnPoints");
			if (spawnPoints != null) {
				for (int i = 0; i < spawnPoints.transform.childCount; i++) {
					GameObject c = spawnPoints.transform.GetChild (i).gameObject;
					if (c.name == globalScript.previousScene) {
						transform.position = c.transform.position;
						GameObject orient = c.transform.GetChild (0).gameObject;
						if (orient.name == "back") {
							characterAnimScript.flip = true;
						}
						break;
					}
				}
			}
		}

		keepCameraOnCharacter (true);
	}
Esempio n. 5
0
    void Awake()
    {
        facingRight = initialRight;

        anim        = GetComponent <Animator>();
        rigidBody   = GetComponent <Rigidbody2D>();
        puppet      = GetComponent <Puppet2D_GlobalControl>();
        collider    = GetComponent <BoxCollider2D>();
        audioSource = GetComponent <AudioSource>();

        if (puppet)
        {
            facingRight = puppet.flip;
        }
    }
Esempio n. 6
0
    public static void AutoRig()
    {
        Puppet2D_Guides[] guides = FindObjectsOfType <Puppet2D_Guides> ();

        foreach (Puppet2D_Guides guide in guides)
        {
            Undo.RegisterCompleteObjectUndo(guides, "guides");

            // Set controls
            Transform _hipPoint   = guide.transform.FindChild("hip_guide").transform;
            Transform _chestPoint = guide.transform.FindChild("chest_guide").transform;

            Transform _thighLPoint = guide.transform.FindChild("thighL_guide").transform;
            Transform _footLPoint  = guide.transform.FindChild("footL_guide").transform;

            Transform _thighRPoint = guide.transform.FindChild("thighR_guide").transform;
            Transform _footRPoint  = guide.transform.FindChild("footR_guide").transform;

            Transform _armLPoint  = guide.transform.FindChild("armL_guide").transform;
            Transform _handLPoint = guide.transform.FindChild("handL_guide").transform;

            Transform _armRPoint  = guide.transform.FindChild("armR_guide").transform;
            Transform _handRPoint = guide.transform.FindChild("handR_guide").transform;

            Transform _headPoint = guide.transform.FindChild("head_guide").transform;

            Transform _elbowLPoint = guide.transform.FindChild("elbowL_guide").transform;
            Transform _kneeLPoint  = guide.transform.FindChild("kneeL_guide").transform;

            Transform _elbowRPoint = guide.transform.FindChild("elbowR_guide").transform;
            Transform _kneeRPoint  = guide.transform.FindChild("kneeR_guide").transform;


            // Hide other global controls

            Puppet2D_GlobalControl[] globalControls = FindObjectsOfType <Puppet2D_GlobalControl>();
            foreach (Puppet2D_GlobalControl gc in globalControls)
            {
                gc.gameObject.SetActive(false);
            }

            GameObject[] gos      = guide.Biped;
            Bounds[]     bounds   = new Bounds[gos.Length];
            string[]     geoNames = new string[gos.Length];


            MakeSpine(_hipPoint, _chestPoint, _footLPoint.position);

            Vector3 _footLEnd = new Vector3(_footLPoint.position.x, guide.Bounds.min.y * .95f, _footLPoint.position.z);
            MakeLimb(_thighLPoint, _footLPoint, _kneeLPoint, _footLEnd, GameObject.Find("Spine_01"), "legL", "thighL", "kneeL", "footL", true);

            Vector3 _footREnd = new Vector3(_footRPoint.position.x, guide.Bounds.min.y * .95f, _footRPoint.position.z);
            MakeLimb(_thighRPoint, _footRPoint, _kneeRPoint, _footREnd, GameObject.Find("Spine_01"), "legR", "thighR", "kneeR", "footR", true);

            MakeClav(GameObject.Find("Spine_05"), "clavL");
            Vector3 _handLEnd = new Vector3(guide.Bounds.max.x * .95f, _handLPoint.position.y, _handLPoint.position.z);
            MakeLimb(_armLPoint, _handLPoint, _elbowLPoint, _handLEnd, GameObject.Find("clavL"), "armL", "shoulderL", "elbowL", "handL", false);
//            Selection.activeGameObject = GameObject.Find("clavL");
//            Puppet2D_CreateControls.CreateOrientControl();

            MakeClav(GameObject.Find("Spine_05"), "clavR");
            Vector3 _handREnd = new Vector3(guide.Bounds.min.x * .95f, _handRPoint.position.y, _handRPoint.position.z);
            MakeLimb(_armRPoint, _handRPoint, _elbowRPoint, _handREnd, GameObject.Find("clavR"), "armR", "shoulderR", "elbowR", "handR", false);
//            Selection.activeGameObject = GameObject.Find("clavR");
//            Puppet2D_CreateControls.CreateOrientControl();


            Vector3 headTop = new Vector3(_headPoint.position.x, guide.Bounds.max.y * .95f, _headPoint.position.z);
            MakeHead(_headPoint, _chestPoint, headTop);


            //SORTING ORDER ON BONES
            GameObject.Find("clavL").GetComponent <SpriteRenderer>().sortingOrder     = -20;
            GameObject.Find("shoulderL").GetComponent <SpriteRenderer>().sortingOrder = -30;
            GameObject.Find("elbowL").GetComponent <SpriteRenderer>().sortingOrder    = -40;
            GameObject.Find("handL").GetComponent <SpriteRenderer>().sortingOrder     = -50;
            GameObject.Find("handLEnd").GetComponent <SpriteRenderer>().sortingOrder  = -50;

            GameObject.Find("thighL").GetComponent <SpriteRenderer>().sortingOrder   = -10;
            GameObject.Find("kneeL").GetComponent <SpriteRenderer>().sortingOrder    = -20;
            GameObject.Find("footL").GetComponent <SpriteRenderer>().sortingOrder    = -30;
            GameObject.Find("footLEnd").GetComponent <SpriteRenderer>().sortingOrder = -30;

            GameObject.Find("clavR").GetComponent <SpriteRenderer>().sortingOrder     = 20;
            GameObject.Find("shoulderR").GetComponent <SpriteRenderer>().sortingOrder = 50;
            GameObject.Find("elbowR").GetComponent <SpriteRenderer>().sortingOrder    = 40;
            GameObject.Find("handR").GetComponent <SpriteRenderer>().sortingOrder     = 30;
            GameObject.Find("handREnd").GetComponent <SpriteRenderer>().sortingOrder  = 30;

            GameObject.Find("thighR").GetComponent <SpriteRenderer>().sortingOrder   = 30;
            GameObject.Find("kneeR").GetComponent <SpriteRenderer>().sortingOrder    = 20;
            GameObject.Find("footR").GetComponent <SpriteRenderer>().sortingOrder    = 10;
            GameObject.Find("footREnd").GetComponent <SpriteRenderer>().sortingOrder = 10;

            SpriteRenderer[] sprites = FindObjectsOfType <SpriteRenderer>();
            List <Object>    objList = new List <Object>();

            for (int i = 0; i < sprites.Length; i++)
            {
                if (sprites[i] && sprites[i].sprite && sprites[i].sprite.name.Contains("Bone") && sprites[i].GetComponent <Puppet2D_HiddenBone>() == null && !sprites[i].name.Contains("clav"))
                {
                    objList.Add(sprites[i].gameObject);
                }
            }
            for (int i = 0; i < gos.Length; i++)
            {
                string originalSpriteName = gos[i].name;
                bounds[i] = gos[i].GetComponent <SpriteRenderer>().bounds;

                Selection.activeGameObject = gos[i];
                bool isSkinned = false;

                foreach (Object obj in objList)
                {
                    GameObject bone = obj as GameObject;
                    if (bounds[i].Contains(bone.transform.position))
                    {
                        if (Vector3.Distance(bounds[i].center, bone.transform.position) < .8f * (bounds[i].size.x / 2f) && Vector3.Distance(bounds[i].center, bone.transform.position) < .8f * (bounds[i].size.y / 2f))
                        {
                            isSkinned = true;
                            break;
                        }
                    }
                }
                if (isSkinned)
                {
                    Puppet2D_Skinning.ConvertSpriteToMesh(5);
                    geoNames[i] = (originalSpriteName + "_GEO");

                    GameObject geo = GameObject.Find(geoNames[i]);
                    if (i == 0)
                    {
                        objList.Add(geo);
                    }
                    else
                    {
                        objList[objList.Count - 1] = geo;
                    }

                    Selection.objects = objList.ToArray();

                    Puppet2D_Skinning.BindSmoothSkin();

                    Selection.activeGameObject = geo;
                }
                else
                {
                    if (i == 0)
                    {
                        objList.Add(gos[i]);
                    }
                    else
                    {
                        objList[objList.Count - 1] = gos[i];
                    }


                    Selection.objects = objList.ToArray();

                    Puppet2D_Skinning.BindRigidSkin();
                }
            }

            Puppet2D_GlobalControl globalControl = FindObjectOfType <Puppet2D_GlobalControl>();
            Animator animator = globalControl.gameObject.AddComponent <Animator>();
            Puppet2d_AnimatorController P2dController = globalControl.gameObject.AddComponent <Puppet2d_AnimatorController>();
            P2dController.speed   = 2f * (_hipPoint.position.y - _footLPoint.position.y);
            P2dController.enabled = false;

            animator.runtimeAnimatorController = (UnityEditor.Animations.AnimatorController)AssetDatabase.LoadAssetAtPath(Puppet2D_Editor._puppet2DPath + "/Animation/AutoRig/P2D_AnimatorController.controller", typeof(UnityEditor.Animations.AnimatorController));
            //globalControl.BonesVisiblity = false;
            //globalControl.UpdateVisibility();
            foreach (Puppet2D_GlobalControl gc in globalControls)
            {
                gc.gameObject.SetActive(true);
            }


            Undo.DestroyObjectImmediate(guide.gameObject);
        }
    }
Esempio n. 7
0
 // Use this for initialization
 void Start()
 {
     _animator      = gameObject.GetComponent <Animator> ();
     _globalControl = gameObject.GetComponent <Puppet2D_GlobalControl> ();
 }
Esempio n. 8
0
 void Start()
 {
     //renderer.enabled = false;
     animator = GetComponent<Animator>();
     pc = GetComponent<Puppet2D_GlobalControl>();
     startRotationY = transform.localRotation.y;
     startScaleX = transform.localScale.x;
 }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        platformWaitTime    = 0;
        highestSortingOrder = -9999;
        findSpritesRecursive(transform);
        highestSortingOrder++;
        globalScript.startingOrderEnemies = highestSortingOrder;

        basePosition      = transform.localPosition;
        thisAnimator      = transform.GetChild(0).GetComponent <Animator> ();
        thisBody          = GetComponent <Rigidbody2D> ();
        thisPuppetControl = transform.GetChild(0).GetComponent <Puppet2D_GlobalControl> ();

        state = "normal";

        if (transform.name == "snail")
        {
            attackDuration  = 1.6f;
            life            = 1;
            attackDelayTime = 1;
            attackPoints    = 10;
            awardedCoins    = 5;
        }
        else if (transform.name == "slime")
        {
            attackDuration  = 1;
            life            = 2;
            attackDelayTime = 0;
            attackPoints    = 12;
            awardedCoins    = 5;
        }
        else if (transform.name == "leaf")
        {
            attackDuration  = 1;
            life            = 1;
            attackDelayTime = 0;
            attackPoints    = 18;
            awardedCoins    = 5;
        }
        else if (transform.name == "spike")
        {
            attackDuration  = 2.55f;
            life            = 1;
            attackDelayTime = 0;
            attackPoints    = 15;
            awardedCoins    = 5;
        }
        else if (transform.name == "armadillo")
        {
            attackDuration  = 1.5f;
            life            = 2;
            attackDelayTime = 1;
            attackPoints    = 20;
            awardedCoins    = 5;
        }
        else if (transform.name == "caterpillar")
        {
            attackDuration  = 1.5f;
            life            = 2;
            attackDelayTime = 0.2f;
            attackPoints    = 20;
            awardedCoins    = 5;
        }
        else if (transform.name == "cactus")
        {
            attackDuration  = 1.5f;
            life            = 2;
            attackDelayTime = 0.2f;
            attackPoints    = 20;
            awardedCoins    = 5;
        }
        else if (transform.name == "spider")
        {
            attackDuration  = 1.5f;
            life            = 2;
            attackDelayTime = 0.2f;
            attackPoints    = 20;
            awardedCoins    = 5;
        }
        else if (transform.name == "fluff")
        {
            attackDuration  = 1.3f;
            life            = 3;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 5;
        }
        else if (transform.name == "octopus")
        {
            attackDuration  = 1.3f;
            life            = 3;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 5;
        }
        else if (transform.name == "bee")
        {
            attackDuration  = 1.3f;
            life            = 3;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 5;
        }
        else if (transform.name == "spikey")
        {
            attackDuration  = 1.3f;
            life            = 3;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 5;
        }
        else if (transform.name == "darkOctopus")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkSpikey")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkBee")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkFluff")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkArmadillo")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkCaterpillar")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkCactus")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkSpider")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkSpike")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkSlime")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkLeaf")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }
        else if (transform.name == "darkSnail")
        {
            attackDuration  = 1.3f;
            life            = 5;
            attackDelayTime = 0.2f;
            attackPoints    = 30;
            awardedCoins    = 10;
        }

        if (movSpeedX > 0)
        {
            changeFaceDirection(true);
        }

        multiTaskTimer = 0;
    }
Esempio n. 10
0
 void Start()
 {
     enemyStats    = GetComponent <EnemyStats>();
     anim          = GetComponent <Animator>();
     puppetControl = GetComponent <Puppet2D_GlobalControl>();
 }
Esempio n. 11
0
    void Awake()
    {
        facingRight = initialRight;

        anim = GetComponent<Animator>();
        rigidBody = GetComponent<Rigidbody2D>();
        puppet = GetComponent<Puppet2D_GlobalControl>();
        collider = GetComponent<BoxCollider2D>();
        audioSource = GetComponent<AudioSource>();

        if(puppet) {
            facingRight = puppet.flip;
        }
    }
Esempio n. 12
0
 public override void OnEnter()
 {
     script      = globalCTRL.Value.GetComponent <Puppet2D_GlobalControl>();
     script.flip = flip.Value;
     Finish();
 }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        Fire();
        animator = gameObject.GetComponentInChildren<Animator>();
        boatOarClass = boatOar.GetComponent<BoatOar>();
        //baconSpotScript = baconSpot.GetComponent<CookingController>();
        p2dControl = gameObject.GetComponentInChildren<Puppet2D_GlobalControl>();

        Transform tempTransform = gameObject.transform.Find("Dolphin 1");
        dolphin = tempTransform.gameObject;

        Transform tempTransform2 = dolphin.transform.Find("bone_47");
        dolphinCollider = tempTransform2.gameObject;
        dolphinCollider =  dolphinCollider.transform.FindDeepChild("dolphin_head_collider").gameObject;
        string StrBacon = baconSpotScript.gameObject.name;
        baconGO = GameObject.Find(StrBacon + "/Bacon");

        rb = getRect(boatEdge);
        pr = getRect(playerHitArea);
        rbs = getRect(baconGO);
        rg = getRect(dolphinCollider);
        //print(rg);
        bo = getRect(boatOar);
    }
Esempio n. 14
0
    // Use this for initialization
    void Start()
    {
        animator = gameObject.GetComponent<Animator>();
        //baconSpotScript = baconSpot.GetComponent<CookingController>();
        p2dControl = gameObject.GetComponent<Puppet2D_GlobalControl>();

        Transform tempTransform = gameObject.transform.Find("bone_4");
        tentecleCollider = tempTransform.gameObject;
        tentecleCollider =  tentecleCollider.transform.FindDeepChild("tent1").gameObject;
        //print("tent1 position: " + tentecleCollider);

        string StrBacon = baconSpotScript.gameObject.name;
        baconGO = GameObject.Find(StrBacon + "/Bacon");
        rg = getRect(objectMesh);
        rb = getRect(boatEdge);
        rs = getRect(screenEdge);
        bo =  getRect(boatOar);

        //Fire();
    }
Esempio n. 15
0
    public void Restore(TargetPackage tp)
    {
        startTime = Time.time;
        baconSpot = tp.bacon;
        playerHitArea = tp.hitArea;
        screenEdge = tp.screenEdge;
        boatEdge = tp.boatEdge;
        playerAttacked = false;
        grabBacon = false;
        boatOar = tp.boatOar;
        p2dControl = gameObject.GetComponent<Puppet2D_GlobalControl>();

        Transform tempTransform = gameObject.transform.Find("bone_4");
        tentecleCollider = tempTransform.gameObject;
        tentecleCollider =  tentecleCollider.transform.FindDeepChild("tent1").gameObject;
        Fire();
    }
Esempio n. 16
0
 void Start()
 {
     AIControl = GetComponent<HMAIControl>();           //获取怪物的ai控制
     PlayerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerHealth>();  //获取玩家健康情况
     Anim = GetComponentInChildren<Animator>();                      //获取状态机
     Puppet2D = GetComponentInChildren<Puppet2D_GlobalControl>();
 }