示例#1
0
    public static LevelProperties ConvertFileToLevelProperties(string fileName)
    {
        var lines = File.ReadAllLines(Strings.LevelDataPath + fileName + ".lvl");

        var gridWidth  = int.Parse(string.Join("", lines[0].Split(':').Skip(1)));
        var gridHeight = int.Parse(string.Join("", lines[1].Split(':').Skip(1)));

        var levelProperties = new LevelProperties(gridWidth, gridHeight);

        var playerData    = string.Join("", lines[2].Split(':').Skip(1));
        var playerIndices = playerData.GetUntilOrEmpty(" ").Split(',');

        levelProperties.PlayerPosX  = int.Parse(playerIndices[0]);
        levelProperties.PlayerPosY  = int.Parse(playerIndices[1]);
        levelProperties.PlayerColor = (PredefinedColor)int.Parse(playerData.Split(' ')[1]);

        for (var i = 3; i < lines.Length; ++i)
        {
            var indices = lines[i].GetUntilOrEmpty(":").Split(',');
            var xIndex  = int.Parse(indices[0]);
            var yIndex  = int.Parse(indices[1]);

            var itemCellData = lines[i].Split(':')[1].Split(' ');

            levelProperties.SetCellEnabled(xIndex, yIndex, itemCellData[0] == "1" ? true : false);
            levelProperties.SetItemType(xIndex, yIndex, (ItemType)int.Parse(itemCellData[1]));
            levelProperties.SetItemColor(xIndex, yIndex, (PredefinedColor)int.Parse(itemCellData[2]));
        }

        return(levelProperties);
    }
示例#2
0
    void OnPopperHit()
    {
        ReduceLifeByOne();
        currentPopper.SetActive(false);
        switch (life)
        {
        case 0: {
            LevelProperties.GetInstance().DecrementPopperCountByOne();
            currentPopper = explotion;
            SetState(POPPER_STATE.DESTROY);
            AudioController.GetInstance().PlayAudio(AudioController.GetInstance().au_Popup);
        }
        break;

        case 1: {
            currentPopper = purplePopper;
        }
        break;

        case 2: {
            currentPopper = bluePopper;
        }
        break;

        default: {
            Debug.Log("Not implemented");
            break;
        }
        }
        currentPopper.SetActive(true);
    }
示例#3
0
    public void ChooseLevelDiff(LevelDifficulties chosenDiff)
    {
        switch (chosenDiff)
        {
        case LevelDifficulties.Normal:
            ChosenLevel = PossibleLevelProperties.Find(p => p.Name == "Normal");
            break;

        case LevelDifficulties.Long:
            ChosenLevel = PossibleLevelProperties.Find(p => p.Name == "Long");
            break;

        case LevelDifficulties.Hardcore:
            ChosenLevel = PossibleLevelProperties.Find(p => p.Name == "Hardcore");
            break;

        case LevelDifficulties.Training:
            ChosenLevel = PossibleLevelProperties.Find(p => p.Name == "Training");
            break;

        default:
            break;
        }
        LevelText.Find(x => x.activeInHierarchy).GetComponent <TextMesh>().text = ChosenLevel.Name;
    }
示例#4
0
        public LevelEditor()
        {
            Behaviours = new BehaviourCollection( );

            const string contentRootFolder = @"c:\";

            _properties = new LevelProperties
            {
                Name              = "Root",
                Visible           = true,
                CustomProperties  = new CustomProperties(),
                ContentRootFolder = contentRootFolder,
                Version           = ObjectFactory.GetInstance <IGetAssemblyInformation>( ).Version
            };

            _previousContentRootFolder = contentRootFolder;

            var contentRootChanged = new ContentRootChanged(_previousContentRootFolder, contentRootFolder);

            ObjectFactory.GetInstance <IEventHub>().Publish(contentRootChanged);

            Layers = new List <LayerEditor>
            {
                new LayerEditor(this, @"Layer_0")
            };
        }
示例#5
0
    void ProcessInput()
    {
        if (!IsActive() || levelDelayer)
        {
            return;
        }

        if (Input.GetMouseButtonUp(0) || Input.touchCount > 0 &&
            GameController.GetInstance().GetGameState() == GameController.GAME_STATE.GAME_GAMEPLAY)
        {
            Vector3      pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(pos, Vector2.zero);
            if (hit.collider != null)
            {
                var hitObject = hit.collider.gameObject.GetComponentInChildren <ProjectileController>(true);
                if (hitObject != null && hit.collider.gameObject == gameObject)
                {
                    OnPopperHit();
                    LevelProperties.GetInstance().IncrementTouchCountByOne();
                }
            }
            else
            {
                Debug.Log("No Hit ");
            }
        }
    }
示例#6
0
        public void EditProperties()
        {
            Ogmo.MainWindow.DisableEditing();
            LevelProperties lp = new LevelProperties(this);

            lp.Show(Ogmo.MainWindow);
        }
示例#7
0
 public void LoadStaticMeshCollectionActors()
 {
     for (int i = 0; i < UStatColl.Count; i++)
     {
         for (int j = 0; j < UStatColl[i].Entries.Count; j++)
         {
             if (UStatColl[i].Entries[j] >= 0 && UStatColl[i].Entries[j] < pcc.Header.ExportCount)
             {
                 UStaticMeshComponent t = new UStaticMeshComponent(pcc.EntryToBuff(UStatColl[i].Entries[j]), pcc.names);
                 t.UPR = UPR;
                 t.Deserialize();
                 LevelProperties LP = UStatColl[i].LP;
                 GlobalTransform g  = new GlobalTransform();
                 g.m      = UStatColl[i].Matrices[j];
                 g.scl    = new Vector3(1, 1, 1);
                 g.scl2   = 1;
                 LP.GT    = g;
                 t.LP     = LP;
                 t.index  = UStatColl[i].Entries[j];
                 t.index2 = j;
                 t.index3 = i;
                 UStatComp.Add(t);
             }
         }
     }
 }
示例#8
0
 public void LoadStaticMeshComponents()
 {
     for (int i = 0; i < UStatComp.Count; i++)
     {
         int entry = UPR.FindObjectProperty("StaticMesh", UStatComp[i].props);
         if (entry >= 0 && entry < pcc.Header.ExportCount)
         {
             if (pcc.getClassName(pcc.Export[entry].Class) == "StaticMesh")
             {
                 UStaticMesh t = new UStaticMesh(pcc.EntryToBuff(entry), pcc.names);
                 t.ReadProperties(4);
                 t.index  = entry;
                 t.index2 = UStatComp[i].index;
                 t.index3 = i;
                 entry    = UPR.FindProperty("Scale3D", UStatComp[i].props);
                 LevelProperties LP = UStatComp[i].LP;
                 GlobalTransform g  = UStatComp[i].LP.GT;
                 if (entry != -1)
                 {
                     Vector3 v = PropToVector3(UStatComp[i].props[entry + 1].raw);
                     g.scl.X *= v.X;
                     g.scl.Y *= v.Y;
                     g.scl.Z *= v.Z;
                 }
                 g.scl *= g.scl2;
                 LP.GT  = g;
                 t.LP   = LP;
                 UStat.Add(t);
             }
         }
     }
 }
示例#9
0
 // Start is called before the first frame update
 void Start()
 {
     Application.targetFrameRate = 60;
     audioSource        = GetComponent <AudioSource>();
     playerBulletSystem = transform.Find("PlayerBulletSystem").GetComponent <BulletSystem>();
     enemyBulletSystem  = transform.Find("EnemyBulletSystem").GetComponent <BulletSystem>();
     cam = transform.Find("Main Camera").GetComponent <Camera>();
     //train = FindObjectOfType<Train>();
     levelProperties = FindObjectOfType <LevelProperties>();
     ui = GetComponentInChildren <UI_Controller>();
     // Load audio clip resources
     audioClips = new Dictionary <string, AudioClip>();
     AudioClip[] clips = Resources.LoadAll <AudioClip>("Sound");
     foreach (AudioClip clip in clips)
     {
         audioClips.Add(clip.name, clip);
         Debug.LogFormat("loaded audio resource {0}", clip.name);
     }
     // Make sure we found everything we need
     Debug.Assert(cam, "Cannot find Main Camera");
     Debug.Assert(playerBulletSystem, "Cannot find PlayerBulletSystem");
     Debug.Assert(enemyBulletSystem, "Cannot find EnemyBulletSystem");
     Debug.Assert(ui, "Cannot find UI_Controller");
     Debug.Assert(audioSource);
 }
    void Start()
    {
        pmc = GameObject.FindWithTag("kinect-pointMan").GetComponent<PointManController>();
        player = GameObject.FindWithTag("Player");

        lProp = GameObject.Find("levelProperties").GetComponent<LevelProperties>();
        pProp = GameObject.Find("hero").GetComponent<PlayerProperties>();
    }
示例#11
0
    public void LoadLevel(int level)
    {
        TextAsset jsonInfo = Resources.Load <TextAsset>("Level/Levels/level_" + level);

        levelProperties = JsonUtility.FromJson <LevelProperties>(jsonInfo.text);

        CreateLevel(levelProperties.crowdSize, levelProperties);
    }
示例#12
0
 // Called when scene is loaded
 private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     levelProperties = FindObjectOfType <LevelProperties>();
     if (levelProperties.levelType == LevelProperties.LevelType.Shop)
     {
         train.gameObject.SetActive(false);
     }
 }
示例#13
0
 private void Update()
 {
     if (GameController.GetInstance().GetGameState() == GameController.GAME_STATE.GAME_GAMEPLAY &&
         LevelProperties.GetInstance() != null)
     {
         currentLevelScore.text = LevelProperties.GetInstance().GetLevelScore().ToString();
         currentTouchCount.text = LevelProperties.GetInstance().GetLevelTouch().ToString();
     }
 }
 void Start()
 {
     score       = GameObject.Find("PointsText").GetComponent <ScoreDisplay>();
     LvlManager  = GameObject.Find("LevelManager").GetComponent <LevelProperties>();
     SNPVariants = GameObject.FindObjectsOfType <SNPVariant>();
     StartCodon  = GameObject.Find("StartBubble").GetComponent <StartStopCodonBehaviour>();
     StopCodon   = GameObject.Find("StopBubble").GetComponent <StartStopCodonBehaviour>();
     Player      = GameObject.FindGameObjectWithTag("Player");
 }
示例#15
0
    public static LevelProperties Parse(string json)
    {
        JSONNode obj = JSON.Parse(json);

        LevelProperties properties = new LevelProperties();

        properties.MaxResource = obj["max_resource"].AsInt;
        properties.DayStart    = new TimeClass(obj["day_start"]);

        if (obj["day_end"] != null)
        {
            properties.DayEnd = new TimeClass(obj["day_end"]);
        }

        if (obj["script"] != null)
        {
            properties.ScriptName = obj["script"];
        }

        properties.ChargingLeft  = obj["charging_left"].AsBool;
        properties.ChargingRight = obj["charging_right"].AsBool;
        properties.ChargingDown  = obj["charging_down"].AsBool;
        properties.ChargingUp    = obj["charging_up"].AsBool;
        properties.Poles         = obj["poles"].AsBool;
        properties.Powerplants   = obj["powerplants"].AsBool;

        if (properties.ChargingLeft)
        {
            properties.ChargingLeftCost = obj["charging_left_cost"].AsInt;
        }
        if (properties.ChargingRight)
        {
            properties.ChargingRightCost = obj["charging_right_cost"].AsInt;
        }
        if (properties.ChargingDown)
        {
            properties.ChargingDownCost = obj["charging_down_cost"].AsInt;
        }
        if (properties.ChargingUp)
        {
            properties.ChargingUpCost = obj["charging_up_cost"].AsInt;
        }
        if (properties.Poles)
        {
            properties.PoleCost   = obj["pole_cost"].AsInt;
            properties.PoleRadius = obj["pole_radius"].AsFloat;
        }
        if (properties.Powerplants)
        {
            properties.PowerplantCost = obj["powerplant_cost"].AsInt;
        }

        return(properties);
    }
示例#16
0
 public void OnLevelExit(bool isScoreUpdated)
 {
     if (isScoreUpdated)
     {
         GameController.GetInstance().AddScore(LevelProperties.GetInstance().GetLevelScore());
         GameController.GetInstance().AddTaps(LevelProperties.GetInstance().GetLevelTouch());
         Debug.Log("Adde touches " + LevelProperties.GetInstance().GetLevelTouch());
     }
     UnloadCurrentLevel();
     GameController.GetInstance().ChangeGameState(GameController.GAME_STATE.GAME_LEVEL_SELECT);
 }
示例#17
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
    // Use this for initialization
    void Start()
    {
        // Get a reference to the DijkstraManager.
        GameObject dijkstraManagerGO = GameObject.FindGameObjectWithTag("Dijkstra");

        dijkstraManager = dijkstraManagerGO.GetComponent <DijkstraManager>();

        // Get a reference to the SoundManager.
        soundManager = FindObjectOfType <SoundManager>();

        // Get a reference to the ScoreTextManager.
        GameObject scoreTextGO = GameObject.FindGameObjectWithTag("ScoreTextManager");

        scoreTexts = scoreTextGO.GetComponent <ScoreTextScript>();

        // Get a reference to the MovementScript.
        movementScript = GameObject.FindGameObjectWithTag("Player").GetComponent <MovementScript>();

        scoreBeer        = FindObjectOfType <ScoreBeer>();
        playerController = FindObjectOfType <PlayerController>();
        LevelProperties lp = FindObjectOfType <LevelProperties>();

        scoreBeer.SetMaxScore(lp.levelMaxScore);    // Set the max score defined in the level properties.

        // Start the dijkstra algorithm.
        dijkstraManager.StartDijkstraAlgorithm(startingRouter.GetComponent <RouterScript>());

        // Perform pre load move.
        movementScript.PerformPreLoadMove(startingRouter);

        movementScript.SubscribeToTargetPositionArrivedEvent(ReachedTargetPoint);

        // UI text fields for dijkstra routing table information.
        routingTableUI = GameObject.FindGameObjectWithTag("RoutingTableUI").GetComponent <RoutingTableUI>();
        routingTableUI.UpdateRoutingTableUI();

        player = FindObjectOfType <MovementScript>().gameObject;

        if (logToFile)
        {
            LevelProperties levelProperties = FindObjectOfType <LevelProperties>();

            Debug.Log("Logging to file!");
            levelLogging = new LevelLogging(levelProperties.levelName, " MaxScore=" + levelProperties.levelMaxScore + ", Type=" + levelProperties.gameType, PlayerPrefs.GetString("name"));
            //audio
            WriteToLog("Sound; Master: " + PlayerPrefs.GetFloat(AudioMenuMain.MASTER_VOL));
            WriteToLog("Sound; Game: " + PlayerPrefs.GetFloat(AudioMenuMain.GAME_VOL));
            WriteToLog("Sound; UI: " + PlayerPrefs.GetFloat(AudioMenuMain.UI_VOL));
            WriteToLog("Sound; Professor: " + PlayerPrefs.GetFloat(AudioMenuMain.PROF_VOL));
            WriteToLog("Sound; Background: " + PlayerPrefs.GetFloat(AudioMenuMain.BACKGROUND_VOL));
            WriteToLogAppendScore("Start; Starting Game");
        }
    }
示例#19
0
    protected override void Awake()
    {
        base.Awake();

        LevelProperties props = FindObjectOfType <LevelProperties>();

        if (props != null)
        {
            CampaignLevelParameters p = props.campaignParams;
            time       = p.timeLimit;
            nutsNeeded = p.minimumNuts;
        }
    }
 public void ApplySettings()
 {
     applySettings = true;
     if (seedField.text.Equals(""))
     {
         var cb = seedField.colors;
         cb.normalColor   = new Color(1f, 0.5f, 0.5f, 1);
         seedField.colors = cb;
         applySettings    = false;
     }
     else
     {
         var cb = seedField.colors;
         cb.normalColor   = new Color(0.5f, 1, 0.5f);;
         seedField.colors = cb;
     }
     if (maxRooms.text.Equals(""))
     {
         var cb = maxRooms.colors;
         cb.normalColor  = new Color(1f, 0.5f, 0.5f, 1);
         maxRooms.colors = cb;
         applySettings   = false;
     }
     else
     {
         var cb = maxRooms.colors;
         cb.normalColor  = new Color(0.5f, 1, 0.5f);;
         maxRooms.colors = cb;
     }
     if (mainPathRooms.text.Equals(""))
     {
         var cb = mainPathRooms.colors;
         cb.normalColor       = new Color(1f, 0.5f, 0.5f, 1);
         mainPathRooms.colors = cb;
         applySettings        = false;
     }
     else
     {
         var cb = mainPathRooms.colors;
         cb.normalColor       = new Color(0.5f, 1, 0.5f);
         mainPathRooms.colors = cb;
     }
     if (applySettings)
     {
         LevelProperties.Changes = true;
         LevelProperties.SetSeed(seedField.text);
         LevelProperties.SetMaxRoomCount(maxRooms.text);
         LevelProperties.SetMainPathRooms(mainPathRooms.text);
         LevelProperties.SetMaxExits((int)maxExits.value);
     }
 }
示例#21
0
 public void LoadStaticMeshActors()
 {
     for (int i = 0; i < UStatActors.Count; i++)
     {
         int entry = UPR.FindObjectProperty("StaticMeshComponent", UStatActors[i].props);
         if (entry >= 0 && entry < pcc.Header.ExportCount)
         {
             UStaticMeshComponent t = new UStaticMeshComponent(pcc.EntryToBuff(entry), pcc.names);
             t.UPR = UPR;
             t.Deserialize();
             LevelProperties LP = UStatActors[i].LP;
             GlobalTransform g  = new GlobalTransform();
             if (i == 21)
             {
             }
             entry = UPR.FindProperty("location", UStatActors[i].props);
             if (entry != -1)
             {
                 g.loc = PropToVector3(UStatActors[i].props[entry + 1].raw);
             }
             entry = UPR.FindProperty("Rotator", UStatActors[i].props);
             if (entry != -1)
             {
                 g.rot = PropToCYPRVector3(UStatActors[i].props[entry].raw);
             }
             entry = UPR.FindProperty("DrawScale3D", UStatActors[i].props);
             if (entry != -1)
             {
                 g.scl = PropToVector3(UStatActors[i].props[entry + 1].raw);
             }
             else
             {
                 g.scl = new Vector3(1, 1, 1);
             }
             entry = UPR.FindProperty("DrawScale", UStatActors[i].props);
             if (entry != -1)
             {
                 g.scl2 = BitConverter.ToSingle(UStatActors[i].props[entry + 1].raw, UStatActors[i].props[entry + 1].raw.Length - 4);
             }
             else
             {
                 g.scl2 = 1;
             }
             LP.GT   = g;
             t.LP    = LP;
             t.index = entry;
             UStatComp.Add(t);
         }
     }
 }
示例#22
0
    private void LoadGameData()
    {
        string filePath = Application.dataPath + gameDataProjectFilePath;

        if (File.Exists(filePath))
        {
            string dataAsJson = File.ReadAllText(filePath);
            levelProps = JsonUtility.FromJson <LevelProperties>(dataAsJson);
        }
        else
        {
            levelProps = new LevelProperties();
        }
    }
    public void LoadLevel(int levelNumber)
    {
        TextAsset jsonInfo = Resources.Load <TextAsset>("Level/level_" + levelNumber);

        levelProperties = JsonUtility.FromJson <LevelProperties>(jsonInfo.text);
        if (level % 9 == 0)
        {
            levelNumber = 0;
            level       = levelNumber;
        }

        GameManager.INSTANCE.uiManager.ResetUI(level);
        CreateLevel(levelNumber);
    }
示例#24
0
        private Level (Guid uid, string name)
        {
            _uid = uid;
            _name = new ResourceName(this, name);

            _layers = new OrderedResourceCollection<Layer>();
            _layers.ResourceAdded += (s, e) => OnLayerAdded(new ResourceEventArgs<Layer>(e.Resource));
            _layers.ResourceRemoved += (s, e) => OnLayerRemoved(new ResourceEventArgs<Layer>(e.Resource));
            _layers.ResourceModified += (s, e) => OnModified(EventArgs.Empty);

            _properties = new PropertyCollection(_reservedPropertyNames);
            _properties.Modified += (s, e) => OnModified(EventArgs.Empty);

            _predefinedProperties = new LevelProperties(this);            
        }
示例#25
0
    /// <summary>
    /// Load game objects based on json values.
    /// </summary>
    /// <param name="jsonStr">Direct json string to process.</param>
    public int Load(string jsonStr, float frontShift)
    {
        LevelProperties level = JsonUtility.FromJson <LevelProperties>(jsonStr);

        GameManager.instance.targetCollection = level.friendlyCubes.Length;
        for (int i = 0; i < level.friendlyCubes.Length; i++)
        {
            GameManager.instance.friendlyPool.SetActiveAtPosition(level.friendlyCubes[i].position + Vector3.forward * frontShift);
        }
        for (int i = 0; i < level.obstacleCubes.Length; i++)
        {
            GameManager.instance.obstaclePool.SetActiveAtPosition(level.obstacleCubes[i].position + Vector3.forward * frontShift);
        }
        return(level.friendlyCubes.Length);
    }
示例#26
0
    // Use this for initialization
    void Awake()
    {
        //TODO: replace with either a generic manager or a check if dijkstra is needed
        LevelProperties levelProp = FindObjectOfType <LevelProperties>();

        if (levelProp.gameType == LevelProperties.GameType.Dijkstra)
        {
            dijkstraManager = GameObject.FindGameObjectWithTag("Dijkstra").GetComponent <DijkstraManager>();
        }
        else if (levelProp.gameType == LevelProperties.GameType.UniformCost)
        {
            uniformCostManager = GameObject.FindGameObjectWithTag("UniformCosts").GetComponent <UniformCostManager>();
        }
        // UI text field for dijkstra routing table information.
        //routingTableTextField = GetComponentInChildren<Text>();
    }
示例#27
0
    public void Init(LevelProperties properties)
    {
        buttons = new List <ToolbarButton>();

        if (properties.ChargingLeft)
        {
            buttons.Add(new ToolbarBuildableButton {
                desc = Buildable.Powerstation_left.GetCost().ToString(), image = Resources.Load("charge-left") as Texture2D, item = Buildable.Powerstation_left
            });
        }
        if (properties.ChargingUp)
        {
            buttons.Add(new ToolbarBuildableButton {
                desc = Buildable.Powerstation_up.GetCost().ToString(), image = Resources.Load("charge-up") as Texture2D, item = Buildable.Powerstation_up
            });
        }
        if (properties.ChargingDown)
        {
            buttons.Add(new ToolbarBuildableButton {
                desc = Buildable.Powerstation_down.GetCost().ToString(), image = Resources.Load("charge-down") as Texture2D, item = Buildable.Powerstation_down
            });
        }
        if (properties.ChargingRight)
        {
            buttons.Add(new ToolbarBuildableButton {
                desc = Buildable.Powerstation_right.GetCost().ToString(), image = Resources.Load("charge-right") as Texture2D, item = Buildable.Powerstation_right
            });
        }
        if (properties.Poles)
        {
            buttons.Add(new ToolbarBuildableButton {
                desc = Buildable.Pole.GetCost().ToString(), image = Resources.Load("pole-text") as Texture2D, item = Buildable.Pole
            });
        }
        if (properties.Powerplants)
        {
            buttons.Add(new ToolbarBuildableButton {
                desc = Buildable.Plant.GetCost().ToString(), image = Resources.Load("powerplant-text") as Texture2D, item = Buildable.Plant
            });
        }
        buttons.Add(new ToolbarActionButton {
            desc = LocaleManager.locale.Undo, image = Resources.Load("undo-icon") as Texture2D, action = controller.UndoAction
        });
        buttons.Add(new ToolbarActionButton {
            desc = LocaleManager.locale.StartDay, image = Resources.Load("play-icon") as Texture2D, action = controller.StartDay
        });
    }
示例#28
0
    // Use this for initialization
    void Awake()
    {
        // Init components.
        professorController = FindObjectOfType <ProfessorController>();
        levelProperties     = FindObjectOfType <LevelProperties>();
        gameState           = FindObjectOfType <GameState>();
        movementManager     = FindObjectOfType <GameMovementManager>();

        // Don't show professor button on tutorial start.
        FindObjectOfType <ProfessorButton>().SetVisible(false);
        // Wait a few seconds on level start, then show professor.
        StartCoroutine(ShowProfessorAfterTime());
        // Disable game play input on tutorial start.
        gameInputEnabled      = false;
        playerWalking         = false;
        showNormalProfOnStart = true;
    }
    protected override void Awake()
    {
        base.Awake();

        LevelProperties props = FindObjectOfType <LevelProperties>();

        if (props != null)
        {
            SurvivalLevelParameters p = props.survivalParams;
            acorn = p.acornPrefab;
            xMin  = p.xMin;
            xMax  = p.xMax;
            yMin  = p.yMin;
            yMax  = p.yMax;
            time  = p.timeOnTimer;
        }
    }
示例#30
0
    // Use this for initialization
    void Start()
    {
        dungeonGenerator = Instantiate(dungeonGenerator);
        dungeonGenerator.transform.parent = this.transform;
        dungeonGenerator.PrepareGeneration();
        if (LevelProperties.HasChanges())
        {
            dungeonGenerator.overridePresetValues(LevelProperties.GetParams());
        }
        dungeonGenerator.GenerateRooms();
        KeyPickUpGenerator = Instantiate(KeyPickUpGenerator);

        maxKeys = KeyPickUpGenerator.generatePickUps(dungeonGenerator.getGeneratedModulesWithStartLeadingAndExitLast());
        keysCollectedGameText.text = "x0 / " + maxKeys;

        moveController = Instantiate(moveController);
        endPanel.gameObject.SetActive(false);
    }
示例#31
0
    public void CreateLevel(int size, LevelProperties levelProperties)
    {
        for (int i = 0; i < levelProperties.levelPieces.Length; i++)
        {
            Obstacle levelBase = Instantiate(obstaclePool.obstaclePool[(int)levelProperties.levelPieces[i].obstacleType], this.transform);
            levelBase.SetObstacleData(levelProperties.levelPieces[i].obstacleSpeed, levelProperties.levelPieces[i].slowMotionSpeed);
            levelPiece.Add(levelBase);
            if (levelProperties.levelPieces[i].obstacleType != Obstacle.TYPE.TYPE0)
            {
                enemyPieces.Add(levelBase.GetComponent <Obstacle>());
                //enemyPieces[enemyPieces.Count-1].obstacleParticle.Stop();
            }
            levelBase.transform.localPosition = start;
            start += new Vector3(chillBase.GetComponent <MeshRenderer>().bounds.size.x, 0, 0);
        }

        CameraManager.INSTANCE.Reset();
        GetCrowd(levelProperties.crowdSize);
    }
示例#32
0
    public void Save()
    {
        LevelProperties levelProperties = new LevelProperties();                                                    // Create a local levelProperty object to convert json data.

        levelProperties.friendlyCubes = new LevelProperties.FriendlyCube[friendlyCubesParent.transform.childCount]; // Create local space for objects array.
        for (int i = 0; i < levelProperties.friendlyCubes.Length; i++)
        {
            levelProperties.friendlyCubes[i] = new LevelProperties.FriendlyCube(friendlyCubesParent.transform.GetChild(i).position); // Store the location information of friendly cube.
        }

        levelProperties.obstacleCubes = new LevelProperties.ObstacleCube[obstacleCubesParent.transform.childCount];
        for (int i = 0; i < levelProperties.obstacleCubes.Length; i++)
        {
            levelProperties.obstacleCubes[i] = new LevelProperties.ObstacleCube(obstacleCubesParent.transform.GetChild(i).position); // Store the location information of obstacle cube.
        }

        string jsonStr = JsonUtility.ToJson(levelProperties, true);           // Convert class to json string.

        File.WriteAllText(path + "/level_" + levelNumber + ".json", jsonStr); // Store json string in a json file. Renamed according to level number.
    }
示例#33
0
 public void LoadLevelObjects(Device d, RichTextBox Rtb=null)
 {
     rtb = Rtb;
     device = d;
     UStatComp = new List<UStaticMeshComponent>();
     UStatActors = new List<UStaticMeshActor>();
     UStatColl = new List<UStaticMeshCollectionActor>();
     UIntAct = new List<UInterpActor>();
     UStat = new List<UStaticMesh>();
     Tex = new List<TextureEntry>();
     TextOut("Loading Level Objects...\n");
     for(int i=0;i<LObjects.Count;i++)
         switch(LObjects[i].cls)
         {
             case "StaticMeshActor":
                 UStaticMeshActor t = new UStaticMeshActor(pcc.EntryToBuff(LObjects[i].entry), pcc.names);
                 t.UPR = UPR;
                 t.Deserialize();
                 LevelProperties LP = new LevelProperties();
                 LP.source = 0;
                 LP.sourceentry = LObjects[i].entry;
                 t.LP = LP;
                 UStatActors.Add(t);
                 break;                    
             case "StaticMeshCollectionActor":
                 UStaticMeshCollectionActor t2 = new UStaticMeshCollectionActor(pcc.EntryToBuff(LObjects[i].entry), pcc);
                 t2.UPR = UPR;
                 t2.Deserialize();
                 LevelProperties LP2 = new LevelProperties();
                 LP2.source = 1;
                 LP2.sourceentry = LObjects[i].entry;
                 t2.LP = LP2;
                 UStatColl.Add(t2);
                 break;
             case "InterpActor":
                 UInterpActor t3 = new UInterpActor(pcc.EntryToBuff(LObjects[i].entry), pcc.names);
                 t3.UPR = UPR;
                 t3.Deserialize();
                 LevelProperties LP3 = new LevelProperties();
                 LP3.source = 2;
                 LP3.sourceentry = LObjects[i].entry;
                 t3.LP = LP3;
                 UIntAct.Add(t3);
                 break;
         }
     TextOut("Loading Static Mesh Actors...\n");
     LoadStaticMeshActors();
     TextOut("Loading Static Mesh Collection Actors...\n");
     LoadStaticMeshCollectionActors();
     TextOut("Loading Interp Actors...\n");
     LoadInterpActors();
     TextOut("Loading Static Mesh Components...\n");
     LoadStaticMeshComponents();
     TextOut("Loading Static Meshes...\n");
     LoadStaticMesh();
     TextOut("Loading Textures...\n");
     LoadTextures();
     TextOut("\nDone");
 }
示例#34
0
 /// <summary>
 /// Returns Level Properties from GameManager gameobject.
 /// </summary>
 /// <returns>
 /// A <see cref="LevelProperties"/>.
 /// </returns>
 private LevelProperties getLevelProperties()
 {
     if (levelProperties == null) {
         levelProperties = GameObject.Find ("GameManager").GetComponent<LevelProperties> ();
     }
     return levelProperties;
 }
示例#35
0
 // Use this for initialization
 void Start()
 {
     if (levelProperties == null) {
         levelProperties = GameObject.Find ("GameManager").GetComponent<LevelProperties> ();
     }
     flySpeed = transform.Find ("Fly Speed").GetComponent<GUIText> ();
 }
示例#36
0
    // Use this for initialization
    void Start()
    {
        if (levelProperties == null) {
            levelProperties = GameObject.Find ("GameManager").GetComponent<LevelProperties> ();
        }

        foreach (TypicalSlot slot in properties.equipmentList.engineSlots) {
            slot.shipParent = this;
        }
        foreach (TypicalSlot slot in properties.equipmentList.hullSlots) {
            slot.shipParent = this;
        }
        foreach (TypicalSlot slot in properties.equipmentList.miscSlots) {
            slot.shipParent = this;
        }
        foreach (TypicalSlot slot in properties.equipmentList.weaponSlots) {
            slot.shipParent = this;
        }

        InitSpaceShip ();
    }
示例#37
0
    // Use this for initialization
    void Start()
    {
        if (levelProperties == null) {
            levelProperties = GameObject.Find ("GameManager").GetComponent<LevelProperties> ();
        }

        playerLastPosition = levelProperties.playerController.ship.transform.position.y;
    }
示例#38
0
 void Start()
 {
     levelProperties = GameObject.Find ("GameManager").GetComponent<LevelProperties> ();
 }