Esempio n. 1
0
    public void SpawnArmL(string objectpath)
    {
        if (ArmLObjects.Count > 0)
        {
            if (actionManager.armorControllers[2] != null)
            {
                actionManager.armorControllers[2].UnEquip();
                actionManager.armorControllers[2] = null;
            }
            if (actionManager.armorAnimControllers[2] != null)
            {
                actionManager.armorAnimControllers[2].RemoveAnimations();
                actionManager.armorAnimControllers[2] = null;
            }
            for (int i = 0; i < ArmLObjects.Count; i++)
            {
                Destroy(ArmLObjects[i]);
            }
            ArmLObjects.Clear();
        }

        GameObject temp = Instantiate(Resources.Load(objectpath) as GameObject) as GameObject;

        temp.transform.parent = ArmLRoot;
        for (int i = 0; i < temp.transform.childCount; i++)
        {
            if (temp.transform.GetChild(i).name == LShoulderRootName)
            {
                ArmLObjects.Add(temp.transform.GetChild(i).gameObject);
                PositionArmL(temp.transform.GetChild(i));
            }
        }
        ArmorSkill armLcontroller = temp.GetComponent <ArmorSkill>();

        if (armLcontroller != null)
        {
            armLcontroller.Initialise(animationTarget, _myTransform, actionManager, (Collider)characterMotor.controller);

            Debug.Log("transfer animation");
        }

        PassiveArmorAnimationController armLAnimController = temp.GetComponent <PassiveArmorAnimationController>();

        if (armLAnimController != null)
        {
            armLAnimController.TransferAnimations(animationTarget, _myTransform);
        }

        actionManager.AddArmorcontroller(armLcontroller, armLAnimController, 2);
        ArmLObjects.Add(temp);
        //ArmorController armLcontroller = ArmL.GetComponent<ArmorController>();

        /*if(armLcontroller != null)
         * {
         *  armLcontroller.TransferAnimations(animationTarget, animationController);
         *  animationController.ArmorControllers[2] = armLcontroller;
         * }*/

        //animationController.UpdateAnimation();
    }