コード例 #1
1
        public override void AssignIndexToObject(InfiniteObject infiniteObject, int index)
        {
            base.AssignIndexToObject(infiniteObject, index);

            for (int i = 0; i < avoidPlatforms.Count; ++i) {
                if (avoidPlatforms[i].AssignIndexToObject(infiniteObject, index))
                    break;
            }
        }
コード例 #2
1
        public virtual void AssignIndexToObject(InfiniteObject infiniteObject, int index)
        {
            for (int i = 0; i < avoidObjectRuleMaps.Count; ++i) {
                avoidObjectRuleMaps[i].AssignIndexToObject(infiniteObject, index);
            }

            for (int i = 0; i < probabilityAdjustmentMaps.Count; ++i) {
                probabilityAdjustmentMaps[i].AssignIndexToObject(infiniteObject, index);
            }
        }
コード例 #3
0
        public override void AssignIndexToObject(InfiniteObject infiniteObject, int index)
        {
            base.AssignIndexToObject(infiniteObject, index);

            for (int i = 0; i < linkedPlatforms.Count; ++i) {
                if (linkedPlatforms[i].AssignIndexToObject(infiniteObject, index)) {
                    PlatformObject platform = infiniteObject as PlatformObject;
                    platform.EnableLinkedSceneObjectRequired();
                    (thisInfiniteObject as SceneObject).sectionTransition = platform.sectionTransition;
                    break;
                }
            }
        }
コード例 #4
0
        public virtual void Init()
        {
            infiniteObjectHistory = InfiniteObjectHistory.instance;
            thisInfiniteObject = GetComponent<InfiniteObject>();

            ObjectType objectType = thisInfiniteObject.GetObjectType();
            for (int i = 0; i < avoidObjectRuleMaps.Count; ++i) {
                avoidObjectRuleMaps[i].Init(infiniteObjectHistory, objectType);
            }

            for (int i = 0; i < probabilityAdjustmentMaps.Count; ++i) {
                probabilityAdjustmentMaps[i].Init(infiniteObjectHistory, objectType);
            }
        }
コード例 #5
0
        public static int AddPlatform(ref List<PlatformPlacementRule> platformPlacementRules, InfiniteObject platform, bool linkedPlatform)
        {
            if (platformPlacementRules == null) {
                platformPlacementRules = new List<PlatformPlacementRule>();
            }
            // Make sure there aren't any duplicates
            for (int i = 0; i < platformPlacementRules.Count; ++i) {
                if (platformPlacementRules[i].platform == platform)
                    return 2;
            }

            platformPlacementRules.Add(new PlatformPlacementRule(platform, linkedPlatform));
            return 0;
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Label("Sections:");
            InfiniteObject infiniteObject = (InfiniteObject)target;
            List <int>     sections       = infiniteObject.sections;

            if (SectionSelectionInspector.ShowSections(ref sections, false))
            {
                infiniteObject.sections = sections;
                EditorUtility.SetDirty(target);
            }
        }
コード例 #7
0
 public void AssignParent(InfiniteObject infiniteObject, ObjectType objectType)
 {
     switch (objectType) {
         case ObjectType.Platform:
             infiniteObject.SetParent(platformParent);
             break;
         case ObjectType.Scene:
             infiniteObject.SetParent(sceneParent);
             break;
         case ObjectType.Obstacle:
             infiniteObject.SetParent(obstacleParent);
             break;
         case ObjectType.Coin:
             infiniteObject.SetParent(coinParent);
             break;
         case ObjectType.PowerUp:
             infiniteObject.SetParent(powerUpParent);
             break;
     }
 }
コード例 #8
0
        public virtual void Deactivate()
        {
            if (destroyOnDeactivation)
            {
                // don't destroy the collision particle effect
                ParticleSystem[] particleSystems = GetComponentsInChildren <ParticleSystem>();
                if (PlayerController.instance)
                {
                    ParticleSystem collisionParticleSystem = PlayerController.instance.collisionParticleSystem;
                    for (int i = 0; i < particleSystems.Length; ++i)
                    {
                        if (particleSystems[i] == collisionParticleSystem)
                        {
                            particleSystems[i].transform.parent = null;
                        }
                    }
                }
                Destroy(gameObject);
                return;
            }

            thisTransform.parent = startParent;
            infiniteObjectParent = null;
            if (optimizeDeactivation)
            {
                foreach (Renderer child in childRenderers)
                {
                    child.enabled = false;
                }
                foreach (Collider child in childColliders)
                {
                    child.enabled = false;
                }
                enabled = false;
            }
            else
            {
                InfiniteRunnerStarterPackUtility.ActiveRecursively(thisTransform, false);
            }
        }
コード例 #9
0
 public void TurnObjectRemoved(bool isSceneObject)
 {
     if (isSceneObject) {
         bottomTurnSceneObjectSpawned = bottomTurnSceneObjectSpawned.GetInfiniteObjectParent();
         if (bottomTurnSceneObjectSpawned == null) {
             topTurnSceneObjectSpawned = null;
         }
     } else {
         bottomTurnPlatformObjectSpawned = bottomTurnPlatformObjectSpawned.GetInfiniteObjectParent();
         if (bottomTurnPlatformObjectSpawned == null) {
             topTurnPlatformObjectSpawned = null;
         }
     }
 }
コード例 #10
0
        // the player has turned. Replace the center values with the corresponding turn values if they aren't -1
        public void Turn(ObjectLocation location)
        {
            for (int i = 0; i < objectSpawnIndex[(int)ObjectLocation.Center].Count; ++i) {
                lastObjectSpawnDistance[(int)ObjectLocation.Center][i] = lastObjectSpawnDistance[(int)location][i];
                if (objectSpawnIndex[(int)location][i] != -1) {
                    objectSpawnIndex[(int)ObjectLocation.Center][i] = objectSpawnIndex[(int)location][i];
                }
            }

            for (int i = 0; i < (int)ObjectLocation.Last; ++i) {
                if (objectTypeSpawnIndex[(int)location][i] != -1) {
                    objectTypeSpawnIndex[(int)ObjectLocation.Center][i] = objectTypeSpawnIndex[(int)location][i];
                }

                lastLocalIndex[(int)ObjectLocation.Center][i] = lastLocalIndex[(int)location][i];
                latestObjectTypeSpawnDistance[(int)ObjectLocation.Center][i] = latestObjectTypeSpawnDistance[(int)location][i];
            }

            totalDistance[(int)ObjectLocation.Center] = totalDistance[(int)location];
            totalSceneDistance[(int)ObjectLocation.Center] = totalSceneDistance[(int)location];
            objectLocationAngle[(int)ObjectLocation.Center] = objectLocationAngle[(int)location];

            platformDistanceDataMap[(int)ObjectLocation.Center].CopyFrom(platformDistanceDataMap[(int)location]);

            previousPlatformSection[(int)ObjectLocation.Center] = previousPlatformSection[(int)location];
            previousSceneSection[(int)ObjectLocation.Center] = previousSceneSection[(int)location];
            spawnedPlatformSectionTransition[(int)ObjectLocation.Center] = spawnedPlatformSectionTransition[(int)location];
            spawnedSceneSectionTransition[(int)ObjectLocation.Center] = spawnedSceneSectionTransition[(int)location];

            // use the center location if there aren't any objects in the location across from the turn location
            ObjectLocation acrossLocation = (location == ObjectLocation.Right ? ObjectLocation.Left : ObjectLocation.Right);
            if (bottomPlatformObjectSpawned[(int)acrossLocation] == null) {
                acrossLocation = ObjectLocation.Center;
            }

            if (topTurnPlatformObjectSpawned != null) {
                topTurnPlatformObjectSpawned.SetInfiniteObjectParent(topPlatformObjectSpawned[(int)ObjectLocation.Center]);
            } else {
                bottomTurnPlatformObjectSpawned = bottomPlatformObjectSpawned[(int)acrossLocation];
            }
            topTurnPlatformObjectSpawned = topPlatformObjectSpawned[(int)ObjectLocation.Center];
            if (topTurnSceneObjectSpawned != null) {
                topTurnSceneObjectSpawned.SetInfiniteObjectParent(topSceneObjectSpawned[(int)ObjectLocation.Center]);
            } else {
                bottomTurnSceneObjectSpawned = bottomSceneObjectSpawned[(int)acrossLocation];
            }
            topTurnSceneObjectSpawned = topSceneObjectSpawned[(int)ObjectLocation.Center];

            topPlatformObjectSpawned[(int)ObjectLocation.Center] = topPlatformObjectSpawned[(int)location];
            bottomPlatformObjectSpawned[(int)ObjectLocation.Center] = bottomPlatformObjectSpawned[(int)location];
            topSceneObjectSpawned[(int)ObjectLocation.Center] = topSceneObjectSpawned[(int)location];
            bottomSceneObjectSpawned[(int)ObjectLocation.Center] = bottomSceneObjectSpawned[(int)location];

            for (int i = (int)ObjectLocation.Left; i < (int)ObjectLocation.Last; ++i) {
                topPlatformObjectSpawned[i] = null;
                bottomPlatformObjectSpawned[i] = null;
                topSceneObjectSpawned[i] = null;
                bottomSceneObjectSpawned[i] = null;
            }
        }
コード例 #11
0
 // the bottom infinite object only needs to be set for the very first object at the object location.. objectRemoved will otherwise take care of making sure the
 // bottom object is correct
 public void SetBottomInfiniteObject(ObjectLocation location, bool isSceneObject, InfiniteObject infiniteObject)
 {
     if (isSceneObject) {
         bottomSceneObjectSpawned[(int)location] = infiniteObject;
     } else {
         bottomPlatformObjectSpawned[(int)location] = infiniteObject;
     }
 }
コード例 #12
0
        // set everything back to 0 for a new game
        public void SaveObjectsReset()
        {
            // save off the current objects. They will be deactivated after new objects have been sapwned
            if (topPlatformObjectSpawned[(int)ObjectLocation.Center] != null) {
                savedInfiniteObjects = topPlatformObjectSpawned[(int)ObjectLocation.Center];

                for (int i = 0; i < (int)ObjectLocation.Last; ++i) {
                    if (i != (int)ObjectLocation.Center && topPlatformObjectSpawned[i])
                        topPlatformObjectSpawned[i].SetInfiniteObjectParent(savedInfiniteObjects);
                    if (bottomPlatformObjectSpawned[i] != null)
                        bottomPlatformObjectSpawned[i].SetInfiniteObjectParent(savedInfiniteObjects);
                    if (topSceneObjectSpawned[i] != null)
                        topSceneObjectSpawned[i].SetInfiniteObjectParent(savedInfiniteObjects);
                    if (bottomSceneObjectSpawned[i] != null)
                        bottomSceneObjectSpawned[i].SetInfiniteObjectParent(savedInfiniteObjects);

                    if (topTurnPlatformObjectSpawned != null)
                        topTurnPlatformObjectSpawned.SetInfiniteObjectParent(savedInfiniteObjects);
                }
            } else {
                // topPlatformObjectSpawned is null when the player turns the wrong way off of a turn
                savedInfiniteObjects = topTurnPlatformObjectSpawned;
            }

            if (bottomTurnPlatformObjectSpawned != null)
                bottomTurnPlatformObjectSpawned.SetInfiniteObjectParent(savedInfiniteObjects);
            if (topTurnSceneObjectSpawned != null)
                topTurnSceneObjectSpawned.SetInfiniteObjectParent(savedInfiniteObjects);
            if (bottomTurnSceneObjectSpawned != null)
                bottomTurnSceneObjectSpawned.SetInfiniteObjectParent(savedInfiniteObjects);

            activeObjectLocation = ObjectLocation.Center;
            for (int i = 0; i < (int)ObjectLocation.Last; ++i) {
                totalDistance[i] = 0;
                totalSceneDistance[i] = 0;
                platformDistanceDataMap[i].ResetValues();
                objectLocationAngle[i] = 0;

                topPlatformObjectSpawned[i] = bottomPlatformObjectSpawned[i] = null;
                topSceneObjectSpawned[i] = bottomSceneObjectSpawned[i] = null;

                previousPlatformSection[i] = 0;
                previousSceneSection[i] = 0;
                spawnedSceneSectionTransition[i] = false;
                spawnedPlatformSectionTransition[i] = false;

                for (int j = 0; j < objectSpawnIndex[i].Count; ++j) {
                    objectSpawnIndex[i][j] = -1;
                    lastObjectSpawnDistance[i][j] = 0;
                }
                for (int j = 0; j < (int)ObjectType.Last; ++j) {
                    objectTypeSpawnIndex[i][j] = -1;
                    lastLocalIndex[i][j] = -1;
                    latestObjectTypeSpawnDistance[i][j] = -1;
                }
            }

            topTurnPlatformObjectSpawned = bottomTurnPlatformObjectSpawned = null;
            topTurnSceneObjectSpawned = bottomTurnSceneObjectSpawned = null;
        }
コード例 #13
0
        // Keep track of the object spawned. Returns the previous object at the top position
        public InfiniteObject ObjectSpawned(int index, float locationOffset, ObjectLocation location, float angle, ObjectType objectType, InfiniteObject infiniteObject)
        {
            lastObjectSpawnDistance[(int)location][index] = (objectType == ObjectType.Scene ? totalSceneDistance[(int)location] : totalDistance[(int)location]) + locationOffset;
            objectTypeSpawnIndex[(int)location][(int)objectType] += 1;
            objectSpawnIndex[(int)location][index] = objectTypeSpawnIndex[(int)location][(int)objectType];
            latestObjectTypeSpawnDistance[(int)location][(int)objectType] = lastObjectSpawnDistance[(int)location][index];
            lastLocalIndex[(int)location][(int)objectType] = infiniteObjectManager.ObjectIndexToLocalIndex(index, objectType);

            InfiniteObject prevTopObject = null;
            if (objectType == ObjectType.Platform) {
                prevTopObject = topPlatformObjectSpawned[(int)location];
                topPlatformObjectSpawned[(int)location] = infiniteObject;
                objectLocationAngle[(int)location] = angle;
            } else if (objectType == ObjectType.Scene) {
                prevTopObject = topSceneObjectSpawned[(int)location];
                topSceneObjectSpawned[(int)location] = infiniteObject;
            }

            return prevTopObject;
        }
コード例 #14
0
ファイル: InfiniteObject.cs プロジェクト: Maareks/Endless-Cat
        public virtual void Deactivate()
        {
            if (destroyOnDeactivation) {
                // don't destroy the collision particle effect
                ParticleSystem[] particleSystems = GetComponentsInChildren<ParticleSystem>();
                if (PlayerController.instance) {
                    ParticleSystem collisionParticleSystem = PlayerController.instance.collisionParticleSystem;
                    for (int i = 0; i < particleSystems.Length; ++i) {
                        if (particleSystems[i] == collisionParticleSystem)
                            particleSystems[i].transform.parent = null;
                    }
                }
                Destroy(gameObject);
                return;
            }

            thisTransform.parent = startParent;
            infiniteObjectParent = null;
            if (optimizeDeactivation) {
                foreach (Renderer child in childRenderers)
                    child.enabled = false;
                foreach (Collider child in childColliders)
                    child.enabled = false;
                enabled = false;
            } else {
                InfiniteRunnerStarterPackUtility.ActiveRecursively(thisTransform, false);
            }
        }
コード例 #15
0
 public void SetInfiniteObjectParent(InfiniteObject parentObject)
 {
     infiniteObjectParent = parentObject;
     thisTransform.parent = parentObject.GetTransform();
 }
コード例 #16
0
 public bool AssignIndexToObject(InfiniteObject infiniteObject, int index)
 {
     if (infiniteObject == platform) {
         platformIndex = index;
         return true;
     }
     return false;
 }
コード例 #17
0
 public PlatformPlacementRule(InfiniteObject p, bool c)
 {
     platform = p;
     canSpawn = c;
 }
コード例 #18
0
        public bool AssignIndexToObject(InfiniteObject obj, int index)
        {
            if (targetObject == null) {
                return false;
            }

            if (obj == targetObject) {
                targetObjectIndex = index;
                targetObjectIsScene = targetObject.GetObjectType() == ObjectType.Scene;
                return true;
            }

            return false;
        }
コード例 #19
0
 public ObjectRuleMap(InfiniteObject io, ScoreObjectCountRule r)
 {
     targetObject = io;
     rules = new List<ScoreObjectCountRule>();
     rules.Add(r);
 }
コード例 #20
0
 // it is a lot of work to adjust for the previous platform start position
 private Vector3 GetPrevPlatformStartPosition(InfiniteObject platform, int platformIndex, Vector3 direction)
 {
     return platformStartPosition[platformIndex].x * platform.GetTransform().right + platformStartPosition[platformIndex].y * Vector3.up +
                 platformStartPosition[platformIndex].z * direction;
 }
コード例 #21
0
        public override void OnInspectorGUI()
        {
            List<ObjectRuleMap> appearanceRules = ((AppearanceRules)target).avoidObjectRuleMaps;
            GUILayout.Label("Avoid Object Rules", "BoldLabel");
            if (appearanceRules != null && appearanceRules.Count > 0) {
                ShowAppearanceRules(appearanceRules, true);
            } else {
                GUILayout.Label("No rules");
            }

            appearanceRules = ((AppearanceRules)target).probabilityAdjustmentMaps;
            GUILayout.Label("Probability Adjustment Rules", "BoldLabel");
            if (appearanceRules != null && appearanceRules.Count > 0) {
                ShowAppearanceRules(appearanceRules, false);
            } else {
                GUILayout.Label("No rules");
            }

            if (addNewRule) {
                avoidObjectRule = GUILayout.SelectionGrid((avoidObjectRule ? 0 : 1), ruleTypeStrings, 2) == 0;

                minDistanceSameObjectType = GUILayout.Toggle(minDistanceSameObjectType, "Use Min Distance with same Object Type");

                GUILayout.BeginHorizontal();
                GUILayout.Label("Min Distance", GUILayout.Width(150));
                string stringValue = GUILayout.TextField(minDistance.ToString());
                try {
                    minDistance = int.Parse(stringValue);
                }
                catch (Exception) { }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Min Object Separation", GUILayout.Width(150));
                stringValue = GUILayout.TextField(minObjectSeperation.ToString());
                try {
                    minObjectSeperation = int.Parse(stringValue);
                }
                catch (Exception) { }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Target Object");
                targetObject = EditorGUILayout.ObjectField(targetObject, typeof(InfiniteObject), false) as InfiniteObject;
                GUILayout.EndHorizontal();

                useEndDistance = GUILayout.Toggle(useEndDistance, "Use End Distance");

                GUILayout.BeginHorizontal();
                GUILayout.Label("Start Distance", GUILayout.Width(120));
                stringValue = GUILayout.TextField(startDistance.ToString());
                try {
                    startDistance = int.Parse(stringValue);
                }
                catch (Exception) { }
                GUILayout.EndHorizontal();

                if (avoidObjectRule && useEndDistance) {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("End Distance", GUILayout.Width(120));
                    stringValue = GUILayout.TextField(endDistance.ToString());
                    try {
                        endDistance = int.Parse(stringValue);
                    }
                    catch (Exception) { }
                    GUILayout.EndHorizontal();
                } else if (!avoidObjectRule) {
                    if (!forceOccurance) {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Start Probability Adj", GUILayout.Width(120));
                        stringValue = GUILayout.TextField(startProbability.ToString());
                        try {
                            startProbability = int.Parse(stringValue);
                        }
                        catch (Exception) { }
                        GUILayout.EndHorizontal();
                    }

                    if (useEndDistance) {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("End Distance", GUILayout.Width(120));
                        stringValue = GUILayout.TextField(endDistance.ToString());
                        try {
                            endDistance = int.Parse(stringValue);
                        }
                        catch (Exception) { }
                        GUILayout.EndHorizontal();

                        if (!forceOccurance) {
                            GUILayout.BeginHorizontal();
                            GUILayout.Label("End Probability Adj", GUILayout.Width(120));
                            stringValue = GUILayout.TextField(endProbability.ToString());
                            try {
                                endProbability = int.Parse(stringValue);
                            }
                            catch (Exception) { }
                            GUILayout.EndHorizontal();
                        }
                    }

                    forceOccurance = GUILayout.Toggle(forceOccurance, "Force Appearance");
                }

                if (addError.Length > 0) {
                    GUI.contentColor = Color.red;
                    GUILayout.Label(addError);
                    GUI.contentColor = Color.white;
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Add")) {
                    int error;
                    if ((error = AddRule()) == 0) {
                        addNewRule = false;
                    } else {
                        switch (error) {
                            case 1:
                                addError = "Error: start distance must be\ngreater than end distance";
                                break;
                            case 2:
                                addError = "Error: Target Object is not set";
                                break;
                            case 3:
                                addError = "Error: Both Min Distance and\nMin Object Seperation are 0";
                                break;
                            case 4:
                                addError = "Error: the rule distances overlap\na different set of rule distances";
                                break;
                            case 5:
                                addError = "Error: another rule already exists\nwhich does not have the end distance set";
                                break;
                            default:
                                addError = "Unknown Error";
                                break;
                        }
                    }
                }

                if (GUILayout.Button("Cancel")) {
                    addNewRule = false;
                }
                GUILayout.EndHorizontal();
            }

            if (!addNewRule && GUILayout.Button("New Rule")) {
                addError = "";
                addNewRule = true;
            }
        }
コード例 #22
0
ファイル: InfiniteObject.cs プロジェクト: Maareks/Endless-Cat
 public void SetInfiniteObjectParent(InfiniteObject parentObject)
 {
     infiniteObjectParent = parentObject;
     thisTransform.parent = parentObject.GetTransform();
 }