Exemplo n.º 1
0
    public void SetAimTarget(Vector3 aimDir)
    {
        //this.aimTargetPosition = aimTargetPosition;
        //Vector3 aimDir = (aimTargetPosition - parentObject.GetPosition()).normalized;

        //debugText = ""+usingSkeletonRight + " " + aimDir;

        // Decide if should use Right or Left Body Part
        if (!isShooting)
        {
            switch (UnitAnim.GetAnimDirFromVector(aimDir))
            {
            default:
            case UnitAnim.AnimDir.Down:
            case UnitAnim.AnimDir.DownRight:
            case UnitAnim.AnimDir.Right:
            case UnitAnim.AnimDir.UpRight:
            case UnitAnim.AnimDir.Up:
                if (!usingSkeletonRight)
                {
                    // Switch sides
                    usingSkeletonRight    = true;
                    activeAnimAimWeapon   = animAimWeaponRight;
                    activeAnimShootWeapon = animShootWeaponRight;
                    unitSkeleton.ReplaceAllBodyPartsInAnimation(activeAnimAimWeapon);
                }
                break;

            case UnitAnim.AnimDir.UpLeft:
            case UnitAnim.AnimDir.Left:
            case UnitAnim.AnimDir.DownLeft:
                if (usingSkeletonRight)
                {
                    // Switch sides
                    //CodeMonkey.CMDebug.TextPopup("ChangeLeft", parentObject.GetPosition());
                    usingSkeletonRight    = false;
                    activeAnimAimWeapon   = animAimWeaponLeft;
                    activeAnimShootWeapon = animShootWeaponLeft;
                    unitSkeleton.ReplaceAllBodyPartsInAnimation(activeAnimAimWeapon);
                }
                break;
            }
        }

        // Show on top of Body for all except Up
        bool weaponOnTopOfBody = UnitAnim.GetAnimDirFromVectorLimit4Directions(aimDir) != UnitAnim.AnimDir.Up;

        int bonusOffset = 2000;

        if (usingSkeletonRight)
        {
            activeAnimAimWeapon.ApplyAimDir(aimDir, positionOffset, weaponOnTopOfBody ? +bonusOffset : -bonusOffset);
            activeAnimShootWeapon.ApplyAimDir(aimDir, positionOffset, weaponOnTopOfBody ? +bonusOffset : -bonusOffset);
        }
        else
        {
            activeAnimAimWeapon.ApplyAimDir(CodeMonkey.Utils.UtilsClass.ApplyRotationToVector(aimDir, 180), positionOffset, weaponOnTopOfBody ? +bonusOffset : -bonusOffset);
            activeAnimShootWeapon.ApplyAimDir(CodeMonkey.Utils.UtilsClass.ApplyRotationToVector(aimDir, 180), positionOffset, weaponOnTopOfBody ? +bonusOffset : -bonusOffset);
        }
    }
Exemplo n.º 2
0
    public void SetAimTarget(Vector3 aimTargetPosition)
    {
        this.aimTargetPosition = aimTargetPosition;

        Vector3 aimDir = (aimTargetPosition - parentObject.GetPosition()).normalized;

        // Decide if should use Inverted Vertical Body Part
        if (!isShooting)
        {
            switch (UnitAnim.GetAnimDirFromVector(aimDir))
            {
            default:
            case UnitAnim.AnimDir.Down:
            case UnitAnim.AnimDir.DownRight:
            case UnitAnim.AnimDir.Right:
            case UnitAnim.AnimDir.UpRight:
            case UnitAnim.AnimDir.Up:
                if (!usingSkeletonNormal)
                {
                    // Switch sides
                    usingSkeletonNormal        = true;
                    activeAnimAimWeaponRight   = animAimWeaponRight;
                    activeAnimShootWeaponRight = animShootWeaponRight;
                    unitSkeleton.ReplaceAllBodyPartsInAnimation(activeAnimAimWeaponRight);
                }
                break;

            case UnitAnim.AnimDir.UpLeft:
            case UnitAnim.AnimDir.Left:
            case UnitAnim.AnimDir.DownLeft:
                if (usingSkeletonNormal)
                {
                    // Switch sides
                    usingSkeletonNormal        = false;
                    activeAnimAimWeaponRight   = animAimWeaponRightInvertV;
                    activeAnimShootWeaponRight = animShootWeaponRightInvertV;
                    unitSkeleton.ReplaceAllBodyPartsInAnimation(activeAnimAimWeaponRight);
                }
                break;
            }
        }

        // Show on top of Body for all except Up
        bool weaponOnTopOfBody = UnitAnim.GetAnimDirFromVectorLimit4Directions(aimDir) != UnitAnim.AnimDir.Up;

        activeAnimAimWeaponRight.ApplyAimDir(aimDir, new Vector3(0, -2), weaponOnTopOfBody ? +1000 : -1000);
        activeAnimShootWeaponRight.ApplyAimDir(aimDir, new Vector3(0, -2), weaponOnTopOfBody ? +1000 : -1000);
    }