Beispiel #1
0
        // function to assign data to object list
        private void assignInfos(XElement root)
        {
            // clear list every time to prevent dupulcation
            Horses.Clear();

            // variables to use later
            double price     = 0.0;
            String horseName = "";
            int    horseID   = 0;

            // get race start time from xml
            String timeStamp = root.Element("races").Element("race").Element("start_time").Value;

            // get all participants details from xml
            var horseInfos = root.Element("races").Element("race").Element("horses").Elements("horse");

            // get horse name, number and price, then assign to list object
            foreach (var horseInfo in horseInfos)
            {
                horseID   = Convert.ToInt32(horseInfo.Element("number").Value);
                horseName = horseInfo.Attribute("name").Value;
                price     = getPrice(root, horseID);

                if (price == 0)
                {
                    Console.WriteLine("Price data didn't match with given horseID\n");
                    return;
                }

                Horses.Add(new Horse(horseID, horseName, price));
            }

            // print out list in order and output json
            CustomUtilities.DisplayAll(timeStamp, Horses, 1);
        }
Beispiel #2
0
        void OnDrawGizmos()
        {
            Vector3 forwardDirection = transform.forward;

            if (characterBody != null)
            {
                if (characterBody.Is2D)
                {
                    forwardDirection = transform.right;
                }
            }

            Vector3 sideDirection = Vector3.Cross(transform.up, forwardDirection);



            Vector3 middleOrigin =
                transform.position + transform.up * (upwardsDetectionOffset) + forwardDirection * (forwardDetectionOffset);

            Vector3 leftOrigin = middleOrigin - sideDirection * (separationBetweenHands / 2f);

            Vector3 rightOrigin = middleOrigin + sideDirection * (separationBetweenHands / 2f);


            CustomUtilities.DrawArrowGizmo(leftOrigin, leftOrigin - transform.up * ledgeDetectionDistance, Color.red, 0.15f);
            CustomUtilities.DrawArrowGizmo(rightOrigin, rightOrigin - transform.up * ledgeDetectionDistance, Color.red, 0.15f);
        }
        public override void OnInspectorGUI()
        {
            CustomUtilities.DrawScriptableObjectField <CharacterActionsAsset>((CharacterActionsAsset)target);

            serializedObject.Update();

            EditorGUILayout.PropertyField(boolActions, true);
            EditorGUILayout.PropertyField(floatActions, true);
            EditorGUILayout.PropertyField(vector2Actions, true);

            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);

            EditorGUILayout.HelpBox(
                "Click the button to replace the original \"CharacterActions.cs\" file. This can be useful if you need to create custom actions, without modifing the code. ",
                MessageType.Info
                );

            if (GUILayout.Button("Create actions"))
            {
                bool result = EditorUtility.DisplayDialog(
                    "Create actions",
                    "Warning: This will replace the original \"CharacterActions\" file. Are you sure you want to continue?", "Yes", "No");

                if (result)
                {
                    CreateCSharpClass();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #4
0
    IEnumerator OnEnemyRushOver()
    {
        // Wait until all enemies are dead.
        while (enemyNumber > 0)
        {
            yield return(null);
        }

        NotificationCentre.PostNotification(this, "OnBGMFadeOut");

        yield return(new WaitForSeconds(1));

        NotificationCentre.PostNotification(this, "OnMissionClear");
        MissionManager.UpdateMission("None.");

        yield return(new WaitForSeconds(1));

        NotificationCentre.PostNotification(this, "OnEventEnter");
        NotificationCentre.PostNotification(this, "OnEnemyRushOver");
        NotificationCentre.PostNotification(this, "OnFadeOut");
        PlayerPrefs.SetString(PlayerPrefsKeys.CHECKPOINT, "PuzzleSolving");

        yield return(new WaitForSeconds(1));

        // Move ZombunnyEvent next to the cannon.
        if (zombunny)
        {
            CustomUtilities.SetPosRot(zombunny.gameObject, new Vector3(4.3f, 13.7f, 28), new Vector3(0, 180, 0));
            zombunny.gameObject.SetActive(true);
            zombunny.followTarget = false;
        }
    }
Beispiel #5
0
        void OnDrawGizmos()
        {
            if (!showGizmos)
            {
                return;
            }


            if (bottomReference != null)
            {
                Gizmos.color = new Color(0f, 0f, 1f, 0.2f);
                Gizmos.DrawCube(bottomReference.position, Vector3.one * 0.5f);
            }

            if (topReference != null)
            {
                Gizmos.color = new Color(1f, 0f, 0f, 0.2f);
                Gizmos.DrawCube(topReference.position, Vector3.one * 0.5f);
            }

            CustomUtilities.DrawArrowGizmo(transform.position, transform.position + FacingDirectionVector, Color.blue);


            Gizmos.color = Color.white;
        }
Beispiel #6
0
        public override void UpdateBehaviour(float dt)
        {
            Vector3 characterPosition = CharacterActor.Position;

            float targetAngularSpeed = CharacterActions.movement.value.x * angularSpeed;


            characterPosition = CustomUtilities.RotatePointAround(
                characterPosition,
                characterPosition + ClosestVectorToRope,
                targetAngularSpeed * dt,
                currentRope.BottomToTop.normalized
                );

            Vector3 targetAngularVelocity = (characterPosition - CharacterActor.Position) / dt;

            angularVelocity = Vector3.MoveTowards(angularVelocity, targetAngularVelocity, angularAcceleration * dt);


            Vector3 targetVerticalVelocity = CharacterActions.movement.value.y * climbSpeed * CharacterActor.Up;

            verticalVelocity = Vector3.MoveTowards(verticalVelocity, targetVerticalVelocity, verticalAcceleration * dt);

            CharacterActor.Velocity = verticalVelocity + angularVelocity;
        }
        // function to assign data to object list
        private void assignInfos(dynamic SteamDetails, int numHorses)
        {
            // clear list every time to prevent dupulcation
            Horses.Clear();

            // variables to use later
            double price     = 0.0;
            String horseName = "";
            int    horseID   = 0;

            // Use JArray Class to gets child JSON tokens
            var text = SteamDetails["RawData"]["Markets"][0]["Selections"];

            // get race start time from json
            String timeStamp = SteamDetails["RawData"]["StartTime"];

            // get horse name, number and price, then assign to list object
            for (int i = 0; i < numHorses; i++)
            {
                horseID   = text[i]["Tags"]["participant"];
                horseName = text[i]["Tags"]["name"];
                price     = text[i]["Price"];
                Horses.Add(new Horse(horseID, horseName, price));
            }

            // print out list in order and output json
            CustomUtilities.DisplayAll(timeStamp, Horses, 2);
        }
Beispiel #8
0
    IEnumerator OnPanOut()
    {
        NotificationCentre.PostNotification(this, "OnPanOut");

        if (vfxcam)
        {
            //CustomUtilities.SetPosRot (vfxcam, new Vector3(5,1,5), new Vector3(0,-35,0));

            yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, Vector3.zero, new Vector3(1, -45, 0), 0.5f)));

            StartCoroutine(CustomUtilities.MovLocRot(vfxcam, new Vector3(15, 0, -8), Vector3.zero, 2));

            //CustomUtilities.SetPosRot (vfxcam, new Vector3(18,1,-3), new Vector3(0,-35,0));
        }

        NotificationCentre.PostNotification(this, "OnBattleBGM");

        yield return(new WaitForSeconds(3));

        NotificationCentre.PostNotification(this, "OnFadeOut");

        yield return(new WaitForSeconds(1.5f));

        if (vfxcam)
        {
            vfxcam.SetActive(false);
        }

        NotificationCentre.PostNotification(this, "OnFadeIn");
        NotificationCentre.PostNotification(this, "OnEventExit");
        NotificationCentre.PostNotification(this, "OnBattleBegin");

        MissionManager.UpdateMission("Survive  the  horde.");
    }
Beispiel #9
0
    IEnumerator OnEnemyAppear()
    {
        if (zombunny)
        {
            CustomUtilities.SetPosRot(zombunny.gameObject, Vector3.zero, Vector3.zero);
            zombunny.gameObject.SetActive(true);
        }

        yield return(new WaitForSeconds(1));

        GameObject player = GameObject.FindWithTag("Player");

        if (player && zombunny)
        {
            zombunny.Target = player;
        }
        //zombunny.followTarget = true;

        if (zombunny)
        {
            yield return(StartCoroutine(CustomUtilities.MovLocRot(zombunny.gameObject, Vector3.zero, new Vector3(0, 90, 0), 0.5f)));
        }

        yield return(new WaitForSeconds(0.75f));

        StartCoroutine(OnZombunnyAppear());
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            CustomUtilities.DrawMonoBehaviourField <CharacterBody>((CharacterBody)target);

            if (monoBehaviour.transform.localScale != Vector3.one)
            {
                GUI.color = Color.red;
                GUILayout.BeginVertical("Box");
            }

            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);
            DrawSize();

            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);
            EditorGUILayout.PropertyField(mass);

            GUILayout.Space(10f);

            if (monoBehaviour.transform.localScale != Vector3.one)
            {
                EditorGUILayout.HelpBox("Transform local scale is not <1,1,1>!", MessageType.Warning);
            }

            if (monoBehaviour.transform.localScale != Vector3.one)
            {
                GUILayout.EndVertical();
            }

            GUI.color = Color.white;

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            CustomUtilities.DrawMonoBehaviourField <NodeBasedPlatform>(monoBehaviour);

            GUILayout.Space(10);

            GUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.Label("Debug Options", EditorStyles.boldLabel);
            GUILayout.Space(5);

            EditorGUILayout.PropertyField(drawHandles);

            GUILayout.EndVertical();


            GUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.Label("Actions", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(move);
            EditorGUILayout.PropertyField(rotate);


            reorderableList.DoLayoutList();

            if (deletedObjectIndex != -1)
            {
                actionsList.DeleteArrayElementAtIndex(deletedObjectIndex);
                deletedObjectIndex = -1;
            }

            if (GUILayout.Button("Add Node", EditorStyles.miniButton))
            {
                monoBehaviour.ActionsList.Add(new PlatformNode());
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical(EditorStyles.helpBox);

            GUILayout.Label("Properties", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(sequenceType);
            EditorGUILayout.PropertyField(positiveSequenceDirection);

            EditorGUILayout.PropertyField(globalSpeedModifier);


            GUILayout.EndVertical();



            serializedObject.ApplyModifiedProperties();

            //SceneView.RepaintAll();
        }
Beispiel #12
0
    void Awake()
    {
        player = GameObject.FindWithTag("Player");
        cam    = GameObject.FindWithTag("MainCamera").GetComponent <CameraMovement> ();

        CustomUtilities.SetPosRot(cam.gameObject, new Vector3(0, 6, -47), new Vector3(20, 0, 0));

        CameraDefault();
    }
Beispiel #13
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            CustomUtilities.DrawMonoBehaviourField <CharacterBrain>((CharacterBrain)target);

            GUILayout.Space(10);



            GUILayout.BeginHorizontal();

            GUI.color = isAI.boolValue ? Color.white : Color.green;
            if (GUILayout.Button("Human", EditorStyles.miniButton))
            {
                isAI.boolValue = false;
            }

            GUI.color = !isAI.boolValue ? Color.white : Color.green;
            if (GUILayout.Button("AI", EditorStyles.miniButton))
            {
                isAI.boolValue = true;
            }

            GUI.color = Color.white;


            GUILayout.EndHorizontal();

            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);

            GUILayout.Space(15);

            if (isAI.boolValue)
            {
                EditorGUILayout.PropertyField(aiBehaviour);

                GUILayout.Space(10);

                CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);
            }
            else
            {
                EditorGUILayout.PropertyField(inputHandlerSettings);
                GUILayout.Space(10);
            }

            GUI.enabled = false;
            EditorGUILayout.PropertyField(characterActions, true);
            GUI.enabled = true;

            GUILayout.Space(10);

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #14
0
        void OnTriggerEnter(Collider otherCollider)
        {
            Rigidbody rigidbody = CustomUtilities.GetOrRegisterValue <Transform, Rigidbody>(rigidbodies, otherCollider.transform);

            if (rigidbody == null)
            {
                return;
            }

            rigidbody.mass *= massMultiplier;
            rigidbody.drag *= dragMultiplier;
        }
Beispiel #15
0
    IEnumerator OnZoomInCannon()
    {
        if (cam)
        {
            cam.SetCameraFollow(false);
            CustomUtilities.SetPosRot(cam.gameObject, new Vector3(0, 1, -3), Vector3.zero);
        }

        NotificationCentre.PostNotification(this, "OnFadeIn");
        NotificationCentre.PostNotification(this, "OnBGMFadeIn");

        yield return(new WaitForSeconds(3));

        // Final Pos (3,16,24) Rot (25,30,0)
        if (cam)
        {
            yield return(StartCoroutine(CustomUtilities.MovLocRot(cam.gameObject, new Vector3(3, 15, 27), new Vector3(25, 30, 0), 2)));
        }

        yield return(new WaitForSeconds(1));

        NotificationCentre.PostNotification(this, "OnZombunnyLaugh");

        yield return(new WaitForSeconds(0.5f));

        NotificationCentre.PostNotification(this, "OnIgniteCannon");

        yield return(new WaitForSeconds(0.5f));

        if (cam)
        {
            // Final Pos (3,16,24) Rot (35,45,0)
            yield return(StartCoroutine(CustomUtilities.MovLocRot(cam.gameObject, Vector3.zero, new Vector3(10, 15, 0), 0.7f)));

            // Final Pos (4.2,16.8,22) Rot (35,5,0)
            yield return(StartCoroutine(CustomUtilities.MovLocRot(cam.gameObject, new Vector3(1.2f, 0.8f, -2), new Vector3(0, -40, 0), 0.8f)));
        }

        NotificationCentre.PostNotification(this, "OnFadeOut");

        yield return(new WaitForSeconds(1));

        OnCameraNormalize();
        NotificationCentre.PostNotification(this, "OnEventExit");
        NotificationCentre.PostNotification(this, "OnEnemyRushOverExit");
        NotificationCentre.PostNotification(this, "OnNaturalSpawn");
        NotificationCentre.PostNotification(this, "OnFadeIn");
        MissionManager.UpdateMission("This  room  is  a  nightmare!  Find  the  way  out.");

        yield return(new WaitForSeconds(3));

        NotificationCentre.PostNotification(this, "ActivateCannon");
    }
Beispiel #16
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            CustomUtilities.DrawScriptableObjectField <MaterialsProperties>((MaterialsProperties)target);

            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray, 8);
            EditorGUILayout.LabelField("Default material", EditorStyles.boldLabel);

            EditorGUILayout.HelpBox("A default material parameter corresponds to any ground or spatial volume without a specific \"material tag\". " +
                                    "A Surface affects grounded movement, while a Volume affects not grounded movement.", MessageType.Info);
            GUILayout.Space(10);

            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);

            EditorGUILayout.LabelField("Default surface", EditorStyles.boldLabel);
            CustomUtilities.DrawArrayElement(defaultSurface, null, true);

            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);

            EditorGUILayout.LabelField("Default volume", EditorStyles.boldLabel);
            CustomUtilities.DrawArrayElement(defaultVolume, null, true);

            // --------------------------------------------------------------------------------------------------------

            GUILayout.Space(10);



            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray);


            EditorGUILayout.LabelField("Tagged materials", EditorStyles.boldLabel);
            GUILayout.Space(10);


            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray, 8);
            EditorGUILayout.LabelField("Surfaces", EditorStyles.boldLabel);

            CustomUtilities.DrawArray(surfaces, "tagName");


            CustomUtilities.DrawEditorLayoutHorizontalLine(Color.gray, 8);

            EditorGUILayout.LabelField("Volumes", EditorStyles.boldLabel);

            CustomUtilities.DrawArray(volumes, "tagName");



            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            CustomUtilities.DrawMonoBehaviourField <AISequenceBehaviour>((AISequenceBehaviour)target);
            serializedObject.Update();

            GUILayout.Space(10);

            reorderableList.DoLayoutList();

            GUILayout.Space(10);

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #18
0
    IEnumerator OnEnemyRushOver()
    {
        if (gun)
        {
            gun.EnableGun(false);
        }
        yield return(new WaitForSeconds(1));

        if (player)
        {
            CustomUtilities.SetPosRot(player, Vector3.zero, new Vector3(0, 180, 0));
        }

        NotificationCentre.PostNotification(this, "OnZoomInCannon");
    }
Beispiel #19
0
    IEnumerator OnEnemyAppear()
    {
        if (vfxcam)
        {
            splashEffect.SetActive(false);;
            vfxcam.SetActive(true);

            CustomUtilities.SetPosRot(vfxcam, new Vector3(22, 2, -2), new Vector3(20, -70, 0));

            NotificationCentre.PostNotification(this, "OnSFXSwift");

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, new Vector3(-18.5f, 0, 0), Vector3.zero, 0.7f)));
        }
    }
Beispiel #20
0
    void OnUpdatePlayer()
    {
        player = GameObject.FindWithTag("Player");

        // Glide camera in.
        if (player && cam)
        {
            cam.SetCameraOffset(new Vector3(0, 5, -7));
            cam.SetCameraTarget(player);
            cam.SetCameraFollow(true);

            //OnCameraNormalize ();

            CustomUtilities.SetPosRot(cam.gameObject, player.transform.position + new Vector3(-2, 6, -6), new Vector3(40, 0, 0));
        }
    }
Beispiel #21
0
        void UpdateEdgeInfo(ref CollisionInfo collisionInfo, Vector3 position, HitInfoFilter hitInfoFilter)
        {
            Vector3 center = characterActor.GetBottomCenter(position, characterActor.StepOffset);

            Vector3 castDirection    = (collisionInfo.hitInfo.point - center).normalized;
            Vector3 castDisplacement = castDirection * CharacterConstants.EdgeRaysCastDistance;

            Vector3 upperHitPosition = center + characterActor.Up * CharacterConstants.EdgeRaysSeparation;
            Vector3 lowerHitPosition = center - characterActor.Up * CharacterConstants.EdgeRaysSeparation;

            HitInfo upperHitInfo;

            physicsComponent.Raycast(
                out upperHitInfo,
                upperHitPosition,
                castDisplacement,
                hitInfoFilter
                );


            HitInfo lowerHitInfo;

            physicsComponent.Raycast(
                out lowerHitInfo,
                lowerHitPosition,
                castDisplacement,
                hitInfoFilter
                );


            collisionInfo.edgeUpperNormal = upperHitInfo.normal;
            collisionInfo.edgeLowerNormal = lowerHitInfo.normal;

            collisionInfo.edgeUpperSlopeAngle = Vector3.Angle(collisionInfo.edgeUpperNormal, characterActor.Up);
            collisionInfo.edgeLowerSlopeAngle = Vector3.Angle(collisionInfo.edgeLowerNormal, characterActor.Up);

            collisionInfo.edgeAngle = Vector3.Angle(collisionInfo.edgeUpperNormal, collisionInfo.edgeLowerNormal);

            collisionInfo.isAnEdge = CustomUtilities.isBetween(collisionInfo.edgeAngle, CharacterConstants.MinEdgeAngle, CharacterConstants.MaxEdgeAngle, true);
            collisionInfo.isAStep  = CustomUtilities.isBetween(collisionInfo.edgeAngle, CharacterConstants.MinStepAngle, CharacterConstants.MaxStepAngle, true);
        }
Beispiel #22
0
    IEnumerator OnPlayerActivate()
    {
        if (player)
        {
            player.SetActive(true);
            gun.EnableGun(false);
            SetPlayerPosRot(new Vector3(21.5f, 0, -1), new Vector3(0, 180, 0));

            yield return(new WaitForSeconds(1));

            ParticleController.Exclamation(player.transform.position, 2);

            yield return(new WaitForSeconds(0.5f));

            yield return(StartCoroutine(CustomUtilities.MovLocRot(player, Vector3.zero, new Vector3(0, 90, 0), 0.5f)));

            yield return(new WaitForSeconds(0.3f));

            NotificationCentre.PostNotification(this, "OnEnemyAppear");
        }
    }
        bool UpdateSlidingPlanes(CollisionInfo collisionInfo, ref Vector3 slidingPlaneNormal, ref Vector3 groundPlaneNormal, ref Vector3 displacement)
        {
            Vector3 normal = collisionInfo.hitInfo.normal;

            if (collisionInfo.contactSlopeAngle > slopeLimit)
            {
                if (slidingPlaneNormal != Vector3.zero)
                {
                    float correlation = Vector3.Dot(normal, slidingPlaneNormal);

                    if (correlation > 0)
                    {
                        displacement = CustomUtilities.DeflectVector(displacement, groundPlaneNormal, normal);
                    }
                    else
                    {
                        displacement = Vector3.zero;
                    }
                }
                else
                {
                    displacement = CustomUtilities.DeflectVector(displacement, groundPlaneNormal, normal);
                }

                slidingPlaneNormal = normal;
            }
            else
            {
                displacement = CustomUtilities.ProjectVectorOnPlane(
                    displacement,
                    normal,
                    Up
                    );

                groundPlaneNormal  = normal;
                slidingPlaneNormal = Vector3.zero;
            }

            return(displacement == Vector3.zero);
        }
        public void CheckVelocityProjection(ref Vector3 displacement)
        {
            bool upwardsDisplacement = transform.InverseTransformVectorUnscaled(displacement).y > 0f;

            if (!upwardsDisplacement)
            {
                return;
            }

            Vector3 modifiedDisplacement = CustomUtilities.ProjectVectorOnPlane(
                displacement,
                Up,
                Up
                );

            // HitInfoFilter filter = new HitInfoFilter(
            //  PhysicsComponent.CollisionLayerMask ,
            //  false ,
            //  true
            // );

            // HitInfo projectionHitInfo;
            // PhysicsComponent.SphereCast(
            //  out projectionHitInfo ,
            //  OffsettedBottomCenter ,
            //  BodySize.x - CharacterConstants.SkinWidth ,
            //  modifiedDisplacement.normalized * ( modifiedDisplacement.magnitude + CharacterConstants.SkinWidth ) ,
            //  filter
            // );

            // if( projectionHitInfo.hit )
            //  return;

            displacement = modifiedDisplacement;

            // if( displacement != Vector3.zero )
        }
Beispiel #25
0
    IEnumerator OnZombearAppear()
    {
        if (zombunny)
        {
            zombunny.Resume();
        }

        GameObject player = GameObject.FindWithTag("Player");

        if (zombear & player)
        {
            zombear.gameObject.SetActive(true);
            zombear.Target = player;

            yield return(new WaitForSeconds(0.3f));

            CustomUtilities.SetPosRot(zombear.gameObject, new Vector3(5, 0, 7), Vector3.zero);
            yield return(StartCoroutine(CustomUtilities.MovLocRot(zombear.gameObject, Vector3.zero, new Vector3(0, -160, 0), 0.5f)));

            zombear.Pause();
        }

        yield return(null);
    }
        void GetContactsInformation()
        {
            bool wasCollidingWithWall = characterCollisionInfo.wallCollision;
            bool wasCollidingWithHead = characterCollisionInfo.headCollision;

            wallContacts.Clear();
            headContacts.Clear();

            for (int i = 0; i < Contacts.Count; i++)
            {
                Contact contact = Contacts[i];

                float verticalAngle = Vector3.Angle(Up, contact.normal);

                // Get the wall information -------------------------------------------------------------
                if (CustomUtilities.isCloseTo(verticalAngle, 90f, CharacterConstants.WallContactAngleTolerance))
                {
                    wallContacts.Add(contact);
                }


                // Get the head information -----------------------------------------------------------------
                if (verticalAngle >= CharacterConstants.MinHeadContactAngle)
                {
                    headContacts.Add(contact);
                }
            }


            if (wallContacts.Count == 0)
            {
                characterCollisionInfo.ResetWallInfo();
            }
            else
            {
                Contact wallContact = wallContacts[0];

                characterCollisionInfo.wallCollision = true;
                characterCollisionInfo.wallAngle     = Vector3.Angle(Up, wallContact.normal);
                characterCollisionInfo.wallContact   = wallContact;

                if (!wasCollidingWithWall)
                {
                    if (OnWallHit != null)
                    {
                        OnWallHit(wallContact);
                    }
                }
            }


            if (headContacts.Count == 0)
            {
                characterCollisionInfo.ResetHeadInfo();
            }
            else
            {
                Contact headContact = headContacts[0];

                characterCollisionInfo.headCollision = true;
                characterCollisionInfo.headAngle     = Vector3.Angle(Up, headContact.normal);
                characterCollisionInfo.headContact   = headContact;

                if (!wasCollidingWithHead)
                {
                    if (OnHeadHit != null)
                    {
                        OnHeadHit(headContact);
                    }
                }
            }
        }
        void HandleLookingDirection(float dt)
        {
            if (lookingDirectionParameters.followExternalReference)
            {
                targetLookingDirection = CharacterStateController.MovementReferenceForward;
            }
            else
            {
                switch (CharacterActor.CurrentState)
                {
                case CharacterActorState.NotGrounded:

                    if (CharacterActor.PlanarVelocity != Vector3.zero)
                    {
                        targetLookingDirection = CharacterActor.PlanarVelocity;
                    }

                    break;

                case CharacterActorState.StableGrounded:

                    if (CharacterStateController.InputMovementReference != Vector3.zero)
                    {
                        targetLookingDirection = CharacterStateController.InputMovementReference;
                    }
                    else
                    {
                        targetLookingDirection = CharacterActor.Forward;
                    }


                    break;

                case CharacterActorState.UnstableGrounded:

                    if (CharacterActor.PlanarVelocity != Vector3.zero)
                    {
                        targetLookingDirection = CharacterActor.PlanarVelocity;
                    }

                    break;
                }
            }


            Quaternion targetDeltaRotation  = Quaternion.FromToRotation(CharacterActor.Forward, targetLookingDirection);
            Quaternion currentDeltaRotation = Quaternion.Slerp(Quaternion.identity, targetDeltaRotation, 10 * dt);



            {
                float angle = Vector3.Angle(CharacterActor.Forward, targetLookingDirection);

                if (CustomUtilities.isCloseTo(angle, 180f, 0.5f))
                {
                    CharacterActor.Forward = Quaternion.Euler(0f, 1f, 0f) * CharacterActor.Forward;
                }

                CharacterActor.Forward = currentDeltaRotation * CharacterActor.Forward;
            }
        }
        void HandlePosition(float dt)
        {
            Vector3 position = Position;

            if (alwaysNotGrounded)
            {
                ForceNotGrounded();
            }

            if (IsKinematic)
            {
                // Process Attached Rigidbody
                if (!IsGrounded)
                {
                    // Check if a "Move" call has been made, if so then use the desiredPosition (RigidbodyComponent)
                    if (moveFlag)
                    {
                        position = RigidbodyComponent.DesiredPosition;
                    }

                    // WIP
                    //ReferenceRigidbodyDisplacement( ref position , attachedRigidbody );

                    Move(position);
                }
            }
            else
            {
                if (IsStable)
                {
                    VerticalVelocity = Vector3.zero;


                    // Weight ----------------------------------------------------------------------------------------------
                    ApplyWeight(GroundContactPoint);


                    Vector3 displacement = CustomUtilities.ProjectVectorOnPlane(
                        Velocity * dt,
                        GroundStableNormal,
                        Up
                        );

                    CollideAndSlide(ref position, displacement, false);

                    ProbeGround(ref position, dt);

                    ProcessDynamicGround(ref position, dt);

                    if (!IsStable)
                    {
                        CurrentTerrain           = null;
                        groundRigidbodyComponent = null;
                    }
                }
                else
                {
                    CollideAndSlideUnstable(ref position, Velocity * dt);
                }

                Move(position);
            }

            moveFlag = false;
        }
Beispiel #29
0
    IEnumerator OnZombunnyAppear()
    {
        if (vfxcam)
        {
            CustomUtilities.SetPosRot(vfxcam, new Vector3(3.5f, 2, -2), new Vector3(20, -70, 0));
            yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, new Vector3(-1.5f, -1.5f, 2), new Vector3(-20, -20, 0), 0.5f)));

            //NotificationCentre.PostNotification (this, "OnSFXVFX1");
            NotificationCentre.PostNotification(this, "OnGooey1");

            if (splashEffect)
            {
                CustomUtilities.SetPosRotLocal(splashEffect, new Vector3(0.15f, 0.55f, 8), Vector3.zero);
                splashEffect.SetActive(true);
            }

            yield return(new WaitForSeconds(0.1f));

            NotificationCentre.PostNotification(this, "OnGooey1");

            if (splashEffect2)
            {
                CustomUtilities.SetPosRotLocal(splashEffect2, new Vector3(-8, -3.5f, 8), Vector3.zero);
                splashEffect2.SetActive(true);
            }

            yield return(new WaitForSeconds(0.1f));

            NotificationCentre.PostNotification(this, "OnGooey2");

            if (splashEffect3)
            {
                CustomUtilities.SetPosRotLocal(splashEffect3, new Vector3(-4, -2, 6), Vector3.zero);
                splashEffect3.SetActive(true);
            }

            if (textZombunny)
            {
                textZombunny.SetActive(true);
            }

            yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, new Vector3(0, 0.2f, -0.1f), Vector3.zero, 4)));

            if (splashEffect)
            {
                splashEffect.SetActive(false);
            }
            if (splashEffect2)
            {
                splashEffect2.SetActive(false);
            }
            if (splashEffect3)
            {
                splashEffect3.SetActive(false);
            }
            if (textZombunny)
            {
                textZombunny.SetActive(false);
            }

            StartCoroutine(OnZombearAppear());
        }
    }
Beispiel #30
0
    IEnumerator OnZombearAppear()
    {
        NotificationCentre.PostNotification(this, "OnZombearAppear");
        NotificationCentre.PostNotification(this, "OnMonsterCry");

        if (vfxcam)
        {
            CustomUtilities.SetPosRot(vfxcam, new Vector3(2, 0.5f, 0), new Vector3(0, -90, 0));
            yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, Vector3.zero, new Vector3(0, 90, 0), 0.3f)));
        }

        yield return(new WaitForSeconds(0.45f));

        //NotificationCentre.PostNotification (this, "OnSFXVFX2");

        if (vfxcam)
        {
            yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, new Vector3(3, 0.5f, 5), Vector3.zero, 0.2f)));
        }

        NotificationCentre.PostNotification(this, "OnGooey2");

        if (splashEffect)
        {
            CustomUtilities.SetPosRotLocal(splashEffect, new Vector3(6, 1.5f, 7), new Vector3(0, 0, 60));
            splashEffect.SetActive(true);
        }

        yield return(new WaitForSeconds(0.1f));

        NotificationCentre.PostNotification(this, "OnGooey1");

        if (splashEffect2)
        {
            CustomUtilities.SetPosRotLocal(splashEffect2, new Vector3(0, -3.5f, 8), new Vector3(0, 0, 90));
            splashEffect2.SetActive(true);
        }

        yield return(new WaitForSeconds(0.1f));

        NotificationCentre.PostNotification(this, "OnGooey1");

        if (splashEffect3)
        {
            CustomUtilities.SetPosRotLocal(splashEffect3, new Vector3(-1, 1, 4), new Vector3(0, 0, 180));
            splashEffect3.SetActive(true);
        }

        if (textZombear)
        {
            textZombear.SetActive(true);
        }

        if (vfxcam)
        {
            yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, Vector3.zero, new Vector3(-1, -5, 0), 4f)));
            //yield return StartCoroutine (CustomUtilities.MovLocRot (vfxcam, new Vector3(-0.2f,0.1f,0), Vector3.zero, 4f));
        }

        if (splashEffect)
        {
            splashEffect.SetActive(false);
        }
        if (splashEffect2)
        {
            splashEffect2.SetActive(false);
        }
        if (splashEffect3)
        {
            splashEffect3.SetActive(false);
        }
        if (textZombear)
        {
            textZombear.SetActive(false);
        }

        StartCoroutine(OnPanOut());
    }