public void StopRangeServo(ArmPart part, bool isGripper = false, bool lightTouch = false)
        {
            //validate
            if (!IsRunning)
            {
                return;
            }

            if (isGripper && lightTouch)
            {
                part.Node.RemoveAction(_rangeGripperLight);
            }
            else if (isGripper)
            {
                part.Node.RemoveAction(_rangeGripper);
            }
            else
            {
                part.Node.RemoveAction(_range);
            }
            part.Node.RunActions(_stopRange);

            //enable recentering
            App.CameraOrbit.AutoCenter = true;
        }
        public void StopSwingServo(ArmPart part)
        {
            //validate
            if (!IsRunning)
            {
                return;
            }

            part.Node.RemoveAllActions();
            part.Node.RunActions(_stopSwing);

            //enable recentering
            App.CameraOrbit.AutoCenter = true;
        }
        public void SwingServo(ArmPart part)
        {
            //validate
            if (!IsRunning)
            {
                return;
            }

            part.Node.RemoveAllActions();
            part.Node.RunActions(_swing);

            //disabled recentering
            App.CameraOrbit.AutoCenter = false;
        }
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (armPart == null)
        {
            armPart = animator.GetComponentInParent <ArmPart>();
        }

        if (stateInfo.IsName("Punch") || stateInfo.IsName("StrongPunch") || stateInfo.IsName("2Handed"))
        {
            armPart.ArmColliders(false, 0);
            armPart.ArmColliders(false, 1);
            armPart.StartedNewAttack(ECombatInputType.NONE);
            //fightSolver.HandleInput();
        }
    }
    public void Attack()
    {
        Debug.Log("atk");
        if (currArm.gameObject.name == "Right Arm Display")
        {
            animator.Play("AIRightPunchWindUp");
        }
        else
        {
            animator.Play("AILeftPunchWindUp");
        }

        currArm = GetRandomArm();
        target  = AIData.Instance.GetNearestTarget(attachedObject);
    }
Exemple #6
0
 // Use this for initialization
 void Awake()
 {
     myCamera  = GetComponentInChildren <CameraController>();
     inventory = GetComponent <Inventory>();
     armPart   = GetComponentInChildren <ArmPart>();
     torsoPart = GetComponentInChildren <TorsoPart>();
     legPart   = GetComponentInChildren <LegPart>();
     AddInitialItems(new GameObject[3] {
         armPart.gameObject, torsoPart.gameObject, legPart.gameObject
     });
     currHp      = torsoPart.maxHp;
     currStamina = torsoPart.maxStamina;
     uiBars      = GetComponent <HandleUIBars>();
     uiBars.UpdateBarMaxValue(0, torsoPart.maxHp);
     uiBars.UpdateBarMaxValue(1, torsoPart.maxStamina);
     uiBars.UpdateBarValue(0, currHp);
     uiBars.UpdateBarValue(1, currStamina);
     startRegeningStamina = false;
     timerRestDelay       = 0;
     armPart.ArmsAddedToBody(this);
     CanAttack = true;
 }
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (armPart == null)
        {
            armPart = animator.GetComponentInParent <ArmPart>();
        }

        if (stateInfo.IsName("Punch") || stateInfo.IsName("StrongPunch") || stateInfo.IsName("2Handed"))
        {
            if (stateInfo.IsName("Punch"))
            {
                armPart.StartedNewAttack(ECombatInputType.WEAK_ATTACK);
            }
            else if (stateInfo.IsName("StrongPunch"))
            {
                armPart.StartedNewAttack(ECombatInputType.STRONG_ATTACK);
            }
            else if (stateInfo.IsName("2Handed"))
            {
                armPart.StartedNewAttack(ECombatInputType.BOTH_ATTACKS);
            }
        }
    }
        public void RangeServo(ArmPart part, bool isGripper = false, bool lightTouch = false)
        {
            //validate
            if (!IsRunning)
            {
                return;
            }

            if (isGripper && lightTouch)
            {
                part.Node.RunActions(_rangeGripperLight);
            }
            else if (isGripper)
            {
                part.Node.RunActions(_rangeGripper);
            }
            else
            {
                part.Node.RunActions(_range);
            }

            //disabled recentering
            App.CameraOrbit.AutoCenter = false;
        }
    public GameObject BuildCharacter(GameObject characterContainer, PartsManager caller = null)
    {
        SetEquippedUsingIndex(equip.equippedParts);

        if (currentTorsoPrefab == null)
        {
            return(null);
        }

        GameObject ad = Instantiate(currentTorsoPrefab, characterContainer.transform, false);

        ad.transform.localPosition = Vector3.zero;
        if (caller != null)
        {
            caller.TorsoEquipped = ad.GetComponent <TorsoPart>();
        }

        TorsoPart parent = ad.GetComponent <TorsoPart>();

        if (currentHeadPrefab != null)
        {
            GameObject adding = Instantiate(currentHeadPrefab, parent.neckForHead.transform, false);
            adding.transform.localPosition = Vector3.zero;
            if (caller != null)
            {
                caller.headEquipped = adding.GetComponent <ItemPart>();
            }
        }

        if (currentLeftArmPrefab != null)
        {
            GameObject adding  = Instantiate(currentLeftArmPrefab, parent.LeftArmUpper.transform, false);
            ArmPart    armPart = adding.GetComponent <ArmPart>();
            armPart.EquipArm(parent, parent.LeftArmUpper, parent.LeftArmFore, parent.LeftArmHand);
            if (caller != null)
            {
                caller.leftArmEquipped = armPart;
            }
        }
        if (currentRightArmPrefab != null)
        {
            GameObject adding  = Instantiate(currentRightArmPrefab, parent.RightArmUpper.transform, false);
            ArmPart    armPart = adding.GetComponent <ArmPart>();

            armPart.EquipArm(parent, parent.RightArmUpper, parent.RightArmFore, parent.RightArmHand);
            if (caller != null)
            {
                caller.rightArmEquipped = armPart;
            }
        }


        if (currentLeftLegPrefab != null)
        {
            GameObject adding  = Instantiate(currentLeftLegPrefab, parent.LeftUpperThigh.transform, false);
            LegPart    legPart = adding.GetComponent <LegPart>();

            legPart.EquipLeg(parent.LeftUpperThigh, parent.Leftshin, parent.LefttAnkle, parent.LeftFoot);
            if (caller != null)
            {
                caller.leftLegEquipped = legPart;
            }
        }
        if (currentRightLegPrefab != null)
        {
            GameObject adding  = Instantiate(currentRightLegPrefab, parent.RightUpperThigh.transform, false);
            LegPart    legPart = adding.GetComponent <LegPart>();

            legPart.EquipLeg(parent.RightUpperThigh, parent.Rightshin, parent.RightAnkle, parent.RightFoot);
            if (caller != null)
            {
                caller.rightLegEquipped = legPart;
            }
        }

        if (parent.bodyType == BodyType.FourArm)
        {
            Debug.Log("Four");

            if (currentRightArmPrefab != null)
            {
                GameObject adding  = Instantiate(currentRightArmPrefab, parent.LowerRightArmUpper.transform, false);
                ArmPart    armPart = adding.GetComponent <ArmPart>();

                armPart.EquipArm(parent, parent.LowerRightArmUpper, parent.LowerRightArmFore, parent.LowerRightArmHand);
            }

            if (currentLeftArmPrefab != null)
            {
                GameObject adding  = Instantiate(currentLeftArmPrefab, parent.LowerLeftArmUpper.transform, false);
                ArmPart    armPart = adding.GetComponent <ArmPart>();

                armPart.EquipArm(parent, parent.LowerLeftArmUpper, parent.LowerLeftArmFore, parent.LowerLeftArmHand);
            }
        }
        return(ad);
    }
Exemple #10
0
 // Use this for initialization
 void Start()
 {
     arms = GetComponentInParent <ArmPart>();
 }
 public override void Init()
 {
     currArm = GetRandomArm();
 }
Exemple #12
0
 private void Awake()
 {
     arms = GetComponentInParent <ArmPart>();
 }
    public void addLimb()
    {
        combinedShop.Refresh = true;

        changed = true;

        GameObject adding;

        GameObject currentPart = combinedShop.currentPart; //The object, found at the index inside the list.

        int currentIndex = combinedShop.currentIndex;

        partType currentType = combinedShop.currentType;



        if (currentPart == null)
        {
            return;
        }


        if (currentType == partType.Torso)
        {
            addingTorso();
            return;
        }

        if (TorsoEquipped == null)
        {
            return;
        }

        switch (currentType)
        {
        case partType.Head:
            if (headEquipped != null && currentPart.name == headEquipped.gameObject.name)
            {
                return;
            }
            if (headEquipped != null)
            {
                Destroy(headEquipped.gameObject);
            }

            adding       = Instantiate(currentPart, TorsoEquipped.neckForHead.transform, false);
            headEquipped = adding.GetComponent <ItemPart>();
            list.ChangeEquip(currentPart, partType.Head, currentIndex);
            adding.name = currentPart.name;
            break;

        case partType.LeftArm:
            if (leftArmEquipped != null && currentPart.name == leftArmEquipped.gameObject.name)
            {
                return;
            }
            if (leftArmEquipped != null)
            {
                leftArmEquipped.deleteArm();
            }
            adding          = Instantiate(currentPart, TorsoEquipped.LeftArmUpper.transform, false);
            leftArmEquipped = adding.GetComponent <ArmPart>();
            leftArmEquipped.EquipArm(TorsoEquipped, TorsoEquipped.LeftArmUpper, TorsoEquipped.LeftArmFore, TorsoEquipped.LeftArmHand);

            adding.name = currentPart.name;
            list.ChangeEquip(currentPart, partType.LeftArm, currentIndex);
            adding = null;
            break;

        case partType.RightArm:
            if (rightArmEquipped != null && currentPart.name == rightArmEquipped.gameObject.name)
            {
                return;
            }
            if (rightArmEquipped != null)
            {
                rightArmEquipped.deleteArm();
            }
            adding = Instantiate(currentPart, TorsoEquipped.RightArmUpper.transform, false);


            rightArmEquipped = adding.GetComponent <ArmPart>();
            rightArmEquipped.EquipArm(TorsoEquipped, TorsoEquipped.RightArmUpper, TorsoEquipped.RightArmFore, TorsoEquipped.RightArmHand);


            adding.name = currentPart.name;
            list.ChangeEquip(currentPart, partType.RightArm, currentIndex);
            adding = null;
            break;

        case partType.LeftLeg:
            if (leftLegEquipped != null && currentPart.name == leftLegEquipped.gameObject.name)
            {
                return;
            }
            if (leftLegEquipped != null)
            {
                leftLegEquipped.DeleteLeg();
            }
            adding          = Instantiate(currentPart, TorsoEquipped.RightUpperThigh.transform, false);
            leftLegEquipped = adding.GetComponent <LegPart>();
            leftLegEquipped.EquipLeg(TorsoEquipped.LeftUpperThigh, TorsoEquipped.Leftshin, TorsoEquipped.LefttAnkle, TorsoEquipped.LeftFoot);


            list.ChangeEquip(currentPart, partType.LeftLeg, currentIndex);
            adding.name = currentPart.name;
            adding      = null;
            break;

        case partType.RightLeg:
            if (rightLegEquipped != null && currentPart.name == rightLegEquipped.gameObject.name)
            {
            }
            if (rightLegEquipped != null)
            {
                rightLegEquipped.DeleteLeg();
            }
            adding           = Instantiate(currentPart, TorsoEquipped.RightUpperThigh.transform, false);
            rightLegEquipped = adding.GetComponent <LegPart>();
            rightLegEquipped.EquipLeg(TorsoEquipped.RightUpperThigh, TorsoEquipped.Rightshin, TorsoEquipped.RightAnkle, TorsoEquipped.RightFoot);


            list.ChangeEquip(currentPart, partType.RightLeg, currentIndex);
            adding.name = currentPart.name;
            adding      = null;
            break;

        default:
            break;
        }

        if (TorsoEquipped.bodyType == BodyType.FourArm)
        {
            Destroy(TorsoEquipped.gameObject);
            list.BuildCharacter(parentOfTorso, this);
            return;
        }
    }