Пример #1
0
 private void StartGame()
 {
     playerController = PlayerController.instance;
     playerTransform = playerController.transform;
     startTime = Time.time;
     approachTime = -visibleDuration;
     thisAnimation.Play(runAnimationName);
     gameActive = true;
     GameManager.instance.OnPauseGame += GamePaused;
 }
Пример #2
0
        private void SpawnCharacter()
        {
            if (activeCharacter == dataManager.GetSelectedCharacter()) {
                return;
            }

            if (character != null) {
                Destroy(character);
            }

            activeCharacter = dataManager.GetSelectedCharacter();
            character = GameObject.Instantiate(dataManager.GetCharacterPrefab(activeCharacter)) as GameObject;
            playerController = PlayerController.instance;
            playerController.Init();

            if (OnPlayerSpawn != null) {
                OnPlayerSpawn();
            }
        }
        public void OnGUI()
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            GUILayout.Label("This wizard will assist in the creation of a new character.\nThe more frequently changed fields are listed and the\nunlisted fields will remain with their default value.\n" +
                            "All of these values can be changed at a later point in time.");
            GUILayout.Space(5);
            GUILayout.Label("Model", "BoldLabel");
            if (model == null) {
                GUI.color = Color.red;
            }
            model = EditorGUILayout.ObjectField("Character Model", model, typeof(GameObject), true) as GameObject;
            GUI.color = Color.white;

            GUILayout.Label("Player", "BoldLabel");
            horizontalSpeed = EditorGUILayout.FloatField("Horizontal Speed", horizontalSpeed);
            jumpHeight = EditorGUILayout.FloatField("Jump Height", jumpHeight);
            slideDuration = EditorGUILayout.FloatField("Slide Duration", slideDuration);
            attackType = (AttackType)EditorGUILayout.EnumPopup("Attack Type", attackType);
            if (attackType == AttackType.Fixed) {
                attackCloseDistance = EditorGUILayout.FloatField("Close Attack Distance", attackCloseDistance);
                attackFarDistance = EditorGUILayout.FloatField("Far Attack Distance", attackFarDistance);
            } else if (attackType == AttackType.Projectile) {
                projectileObject = EditorGUILayout.ObjectField("Projectile", projectileObject, typeof(ProjectileObject), true) as ProjectileObject;
            }
            autoTurn = EditorGUILayout.Toggle("Auto Turn?", autoTurn);
            autoJump = EditorGUILayout.Toggle("Auto Jump?", autoJump);

            DistanceValueListInspector.ShowLoopToggle(ref forwardSpeedList, DistanceValueType.Speed);
            if (forwardSpeedList == null || forwardSpeedList.Count() == 0) {
                GUI.color = Color.red;
            }
            DistanceValueListInspector.ShowDistanceValues(ref forwardSpeedList, DistanceValueType.Speed);
            GUI.color = Color.white;
            DistanceValueListInspector.ShowAddNewValue(ref forwardSpeedList, DistanceValueType.Speed);

            GUILayout.Space(5);
            GUILayout.Label("Particles", "BoldLabel");
            GUILayout.Label("Optionally specify a character to copy the particles from");
            particleSource = EditorGUILayout.ObjectField("Particles Source", particleSource, typeof(PlayerController), true) as PlayerController;

            GUILayout.Space(5);
            GUILayout.Label("Animations", "BoldLabel");
            useMecanim = EditorGUILayout.Toggle("Use Mecanim?", useMecanim);
            if (useMecanim) {
                runStateName = EditorGUILayout.TextField("Run State Name", runStateName);
                jumpStateName = EditorGUILayout.TextField("Jump State Name", jumpStateName);
                slideStateName = EditorGUILayout.TextField("Slide State Name", slideStateName);
                rightStrafeStateName = EditorGUILayout.TextField("Right Strafe State Name", rightStrafeStateName);
                leftStrafeStateName = EditorGUILayout.TextField("Left Strafe State Name", leftStrafeStateName);
                attackStateName = EditorGUILayout.TextField("Attack State Name", attackStateName);
                backwardDeathStateName = EditorGUILayout.TextField("Backward Death State Name", backwardDeathStateName);
                forwardDeathStateName = EditorGUILayout.TextField("Forward Death State Name", forwardDeathStateName);
                idleStateName = EditorGUILayout.TextField("Idle State Name", idleStateName);
            } else {
                runAnimationName = EditorGUILayout.TextField("Run Animation Name", runAnimationName);
                runJumpAnimationName = EditorGUILayout.TextField("Jump Animation Name", runJumpAnimationName);
                runSlideAnimationName = EditorGUILayout.TextField("Slide Animation Name", runSlideAnimationName);
                runRightStrafeAnimationName = EditorGUILayout.TextField("Right Strafe Animation Name", runRightStrafeAnimationName);
                runLeftStrafeAnimationName = EditorGUILayout.TextField("Left Strafe Animation Name", runLeftStrafeAnimationName);
                attackAnimationName = EditorGUILayout.TextField("Attack Animation Name", attackAnimationName);
                backwardDeathAnimationName = EditorGUILayout.TextField("Backward Death Animation Name", backwardDeathAnimationName);
                forwardDeathAnimationName = EditorGUILayout.TextField("Forward Death Animation Name", forwardDeathAnimationName);
                idleAnimationName = EditorGUILayout.TextField("Idle Animation Name", idleAnimationName);
            }

            if (model == null || forwardSpeedList == null || forwardSpeedList.Count() == 0) {
                GUI.enabled = false;
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Create") && GUI.enabled) {
                CreateCharacter();
            }
            GUI.enabled = true;

            GUILayout.EndScrollView();
        }
 private void StartGame()
 {
     playerController = PlayerController.instance;
     playerTransform = playerController.transform;
 }
Пример #5
0
        public void StartGame(bool fromRestart)
        {
            playerController = PlayerController.instance;
            playerTransform = playerController.transform;
            if (fromRestart) {
                targetPosition = inGamePosition;
                targetRotation.eulerAngles = inGameRotation;

                thisTransform.position = playerTransform.TransformPoint(inGamePosition);

                Vector3 relativeTargetRotationVec = inGameRotation;
                relativeTargetRotationVec.y += playerTransform.eulerAngles.y;
                Quaternion relativeTargetRotation = thisTransform.rotation;
                relativeTargetRotation.eulerAngles = relativeTargetRotationVec;
                thisTransform.rotation = relativeTargetRotation;

                transitioning = false;
            } else {
                targetPosition = inGamePosition;
                targetRotation.eulerAngles = inGameRotation;
                transitioning = true;
            }
            gameActive = true;

            GameManager.instance.OnPauseGame += GamePaused;
            isShaking = false;
        }
Пример #6
0
 public void Awake()
 {
     instance = this;
 }