Example #1
0
        // Use this for initialization
        void Start()
        {
            SoundManager.LoadAndEnsureGameMusic(this);
            AvailableAssets      = LevelAssetService.Assets;
            m_originalCameraSize = Camera.orthographicSize;
            Build();
            ApplyPositions(StaticCatastrophyDataBroker.GetLocationPlacementInfo());

            if (StaticCatastrophyDataBroker.IsGameStartMode)
            {
                StartGame();
            }

            UpdateDragPanelToCamera();
        }
Example #2
0
        public void StartGame()
        {
            m_isCurrentlyPlayingGame = true; //<< deactivates drag and drop.
            //m_positionsAtLastGameStart = new Dictionary<LevelAsset, List<Vector3>>();
            List <GameObject> objectsToDestroy = new List <GameObject>();

            //we need to store the current positions now,
            //because later, it's to late (infos get destroyed)
            StaticCatastrophyDataBroker.StoreLocationPlacementInfo(GetPositionInfos());

            //TODO: replace the preview objects with real objects that have physics reanabled.
            foreach (var kvp in m_inScenePreviewObjects)
            {
                //List<Vector3> positions = new List<Vector3>();
                //m_positionsAtLastGameStart.Add(kvp.Key, positions);
                foreach (var previewObject in kvp.Value)
                {
                    objectsToDestroy.Add(previewObject);

                    PreviewCollisionMemory collisionMemory = previewObject.GetComponent <PreviewCollisionMemory>();
                    //only add objects that havent been setup as colliding object.
                    if (!collisionMemory.IsColliding)
                    {
                        GameObject go = (GameObject)Instantiate(kvp.Key.Prefab);
                        go.transform.position = previewObject.transform.position;
                    }
                }
            }

            m_inScenePreviewObjects.Clear();
            m_currentDraggingObject = null;
            m_currentDraggingAsset  = null;

            foreach (GameObject obj in objectsToDestroy)
            {
                Destroy(obj);
            }

            StartStartableGameObjects();
            ApplyCatForce();
        }