Beispiel #1
0
        public void DeActivateMountedState()
        {
            //Debug.Log("MountEffect.DeActivateMountedState()");
            if (prefabObjects != null)
            {
                GameObject go = prefabObjects.Values.ElementAt(0);
                PlayerUnitMovementController playerUnitMovementController = go.GetComponent <PlayerUnitMovementController>();
                if (playerUnitMovementController != null && PlayerManager.MyInstance.MyPlayerUnitObject != null)
                {
                    //Debug.Log("Got Player Unit Movement Controller On Spawned Prefab (mount)");

                    //PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit.MyRigidBody.constraints = RigidbodyConstraints.FreezeAll;

                    //Debug.Log("Setting Animator Values");

                    PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit = PlayerManager.MyInstance.MyPlayerUnitObject.GetComponent <AnimatedUnit>();
                    ConfigureCharacterRegularPhysics();

                    // set player unit to normal state
                    PlayerManager.MyInstance.MyCharacter.MyCharacterUnit.MyMounted = false;
                    if ((PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit as AnimatedPlayerUnit).MyPlayerUnitMovementController)
                    {
                        (PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit as AnimatedPlayerUnit).MyPlayerUnitMovementController.enabled = true;
                    }
                    PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit.MyCharacterAnimator.SetRiding(false);
                    //PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit.MyCharacterAnimator.SetBool("Riding", false);
                    CameraManager.MyInstance.ActivateMainCamera();
                    CameraManager.MyInstance.MyMainCameraController.InitializeCamera(PlayerManager.MyInstance.MyCharacter.MyCharacterUnit.transform);
                }
            }
        }
        public void ActivateMountedState()
        {
            if (prefabObjects != null)
            {
                ConfigureMountPhysics();
                GameObject go = prefabObjects.Values.ElementAt(0);
                PlayerUnitMovementController playerUnitMovementController = go.GetComponent <PlayerUnitMovementController>();
                if (playerUnitMovementController != null)
                {
                    // disable movement and input on player unit
                    (PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit as AnimatedPlayerUnit).MyPlayerUnitMovementController.enabled = false;
                    PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit.MyRigidBody.constraints = RigidbodyConstraints.FreezeAll;

                    //Debug.Log("MountEffect.ActivateMountedState()Setting Animator Values");
                    // set player animator to riding state
                    PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit.MyCharacterAnimator.SetBool("Riding", true);
                    PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit.MyCharacterAnimator.SetTrigger("RidingTrigger");

                    // set player unit to riding state
                    PlayerManager.MyInstance.MyCharacter.MyCharacterUnit.MyMounted = true;

                    ConfigureCharacterMountedPhysics();

                    // initialize the mount animator
                    PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit = go.GetComponent <AnimatedUnit>();
                    PlayerManager.MyInstance.MyCharacter.MyAnimatedUnit.OrchestrateStartup();

                    playerUnitMovementController.SetCharacterUnit(PlayerManager.MyInstance.MyCharacter.MyCharacterUnit);
                    CameraManager.MyInstance.MyMainCameraController.InitializeCamera(go.transform);
                }
            }
        }
Beispiel #3
0
 public override void HandleCharacterUnitDespawn()
 {
     if (BaseCharacter != null && BaseCharacter.AnimatedUnit != null)
     {
         PlayerUnitMovementController movementController = (BaseCharacter.AnimatedUnit as AnimatedPlayerUnit).MyPlayerUnitMovementController;
         if (movementController != null)
         {
             movementController.OnMovement -= HandleManualMovement;
         }
     }
     base.HandleCharacterUnitDespawn();
 }
Beispiel #4
0
 public override void Move(Vector3 moveDirection, bool isKnockBack = false)
 {
     if (isKnockBack)
     {
         PlayerUnitMovementController playerUnitMovementController = (animatedUnit as AnimatedPlayerUnit).MyPlayerUnitMovementController;
         if (playerUnitMovementController != null)
         {
             playerUnitMovementController.KnockBack();
         }
     }
     base.Move(moveDirection, isKnockBack);
 }
        public override void HandleCharacterUnitSpawn()
        {
            PlayerUnitMovementController movementController = (MyBaseCharacter.MyAnimatedUnit as AnimatedPlayerUnit).MyPlayerUnitMovementController;

            //CharacterMotor characterMotor = MyBaseCharacter.MyAnimatedUnit.MyCharacterMotor;
            if (movementController != null)
            {
                //Debug.Log("CharacterAbilityManager.OnCharacterUnitSpawn(): movementController is not null");
                movementController.OnMovement += HandleManualMovement;
            }
            base.HandleCharacterUnitSpawn();
        }
        public override Dictionary <PrefabProfile, GameObject> Cast(IAbilityCaster source, GameObject target, GameObject originalTarget, AbilityEffectContext abilityEffectContext)
        {
            //Debug.Log(DisplayName + ".KnockBackEffect.Cast()");
            if (target == null)
            {
                return(null);
            }

            Dictionary <PrefabProfile, GameObject> returnObjects = base.Cast(source, target, originalTarget, abilityEffectContext);

            Vector3 sourcePosition = source.UnitGameObject.transform.position;
            Vector3 targetPosition = target.transform.position;

            AnimatedUnit  animatedUnit        = target.GetComponent <AnimatedUnit>();
            CharacterUnit targetCharacterUnit = target.GetComponent <CharacterUnit>();

            if (targetCharacterUnit != null && targetCharacterUnit.MyCharacter != null && targetCharacterUnit.MyCharacter.CharacterAbilityManager)
            {
                //Debug.Log("KnockBackEffect.Cast(): stop casting");
                targetCharacterUnit.MyCharacter.CharacterAbilityManager.StopCasting();
            }

            if (knockbackType == KnockbackType.Knockback)
            {
                if (animatedUnit != null && animatedUnit.MyCharacterMotor != null)
                {
                    //Debug.Log("KnockBackEffect.Cast(): casting on character");
                    animatedUnit.MyCharacterMotor.Move(GetKnockBackVelocity(sourcePosition, targetPosition), true);
                }
                else
                {
                    Rigidbody rigidbody = target.GetComponent <Rigidbody>();
                    if (rigidbody != null)
                    {
                        rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
                        rigidbody.AddForce(GetKnockBackVelocity(sourcePosition, targetPosition), ForceMode.VelocityChange);
                    }
                }
            }
            else
            {
                Collider[] colliders = new Collider[0];
                //int playerMask = 1 << LayerMask.NameToLayer("Default");
                //int characterMask = 1 << LayerMask.NameToLayer("CharacterUnit");
                //int validMask = (playerMask | characterMask);
                //int validMask = playerMask;
                //colliders = Physics.OverlapSphere(targetPosition, explosionRadius, validMask);
                Vector3 explosionCenter = Vector3.zero;
                if (abilityEffectContext.groundTargetLocation != Vector3.zero)
                {
                    explosionCenter = abilityEffectContext.groundTargetLocation;
                }
                else
                {
                    explosionCenter = targetPosition;
                }
                colliders = Physics.OverlapSphere(explosionCenter, explosionRadius, explosionMask);
                foreach (Collider collider in colliders)
                {
                    //Debug.Log(DisplayName + ".KnockBackEffect.Cast() hit: " + collider.gameObject.name + "; layer: " + collider.gameObject.layer);
                    Rigidbody rigidbody = collider.gameObject.GetComponent <Rigidbody>();
                    if (rigidbody != null)
                    {
                        //Debug.Log(DisplayName + ".KnockBackEffect.Cast() rigidbody was not null on : " + collider.gameObject.name + "; layer: " + collider.gameObject.layer);

                        //rigidbody.AddForce(GetKnockBackVelocity(targetPosition, collider.gameObject.transform.position), ForceMode.VelocityChange);

                        // we have to handle player knockback specially, as they need to be in knockback state or the idle update will freeze them in place
                        PlayerUnitMovementController playerUnitMovementController = collider.gameObject.GetComponent <PlayerUnitMovementController>();
                        if (playerUnitMovementController != null)
                        {
                            playerUnitMovementController.KnockBack();
                        }

                        // if this is a character, we want to freeze their rotation.  for inanimate objects, we want rotation
                        targetCharacterUnit = collider.gameObject.GetComponent <CharacterUnit>();
                        if (targetCharacterUnit != null)
                        {
                            rigidbody.constraints = RigidbodyConstraints.FreezeRotation;
                        }
                        rigidbody.AddExplosionForce(explosionForce, explosionCenter, 0, upwardModifier, ForceMode.VelocityChange);
                    }
                }
            }

            return(returnObjects);
        }