Beispiel #1
0
        public float CalcDepth(SpatialData spatial, GameLayer layer)
        {
            // Note(manu): 0 means front, 1 means back.
            float maxY  = Level.SCREEN_DIMENSION * CurrentLevel.ScreenTileHeight;
            float y     = MathHelper.Clamp(spatial.Position.Y, 0, maxY);
            float alpha = y / maxY;

            float depth;

            switch (layer)
            {
            case GameLayer.CloseToTheScreen:
                depth = MathHelper.Lerp(0.0999f, 0.0f, alpha);
                break;

            case GameLayer.SomewhereInTheMiddle:
                depth = MathHelper.Lerp(0.9f, 0.1f, alpha);
                break;

            case GameLayer.Background:
                depth = 1.0f;
                break;

            default: throw new ArgumentException("layer");
            }

            return(depth);
        }
        private void ConvertKSHAndOpen()
        {
            var dialog = new OpenFileDialogDesc("Open KSH Chart",
                                                new[] { new FileFilter("K-Shoot MANIA Files", "ksh") });

            var dialogResult = FileSystem.ShowOpenFileDialog(dialog);

            if (dialogResult.DialogResult == DialogResult.OK)
            {
                string primaryKshFile = dialogResult.FilePath;
                var    chartSetInfo   = ConvertKSHAndSave(primaryKshFile, out ChartInfo selected);

                var serializer = BinaryTheoriChartSerializer.GetSerializerFor(NeuroSonicGameMode.Instance);
                using (var stream = File.OpenRead(Path.Combine(m_chartsDir, chartSetInfo.FilePath, selected.FileName)))
                {
                    var    chart     = serializer.DeserializeChart(selected, stream);
                    string audioFile = Path.Combine(m_chartsDir, chartSetInfo.FilePath, chart.Info.SongFileName);

                    var audio = AudioTrack.FromFile(audioFile);
                    audio.Channel = Host.Mixer.MasterChannel;
                    audio.Volume  = chart.Info.SongVolume / 100.0f;

                    AutoPlay autoPlay = AutoPlay.None;
                    if (Keyboard.IsDown(KeyCode.LCTRL) || Keyboard.IsDown(KeyCode.RCTRL))
                    {
                        autoPlay = AutoPlay.ButtonsAndLasers;
                    }

                    var game = new GameLayer(Plugin.DefaultResourceLocator, chart, audio, autoPlay);
                    Host.PushLayer(new GenericTransitionLayer(game, Plugin.DefaultResourceLocator));
                }
            }
        }
 private void instantiateBorder(GameLayer thisLayer)
 {
     //instantiate north and south
     for (int i = 0; i < thisLayer.layerWidth; i++)
     {
         if (!(((curGameLayer.exitWall == Direction.NORTH) && (i == curGameLayer.exitWallLoc)) || ((curGameLayer.entranceWall == Direction.NORTH) && (i == curGameLayer.entranceWallLoc))))
         {
             //did not find a north wall matching exit or entrance, instantiate here
             goInstantiated = Instantiate(basicBorder[0], new Vector3(thisLayer.layerZeroZero.x + (i * roomTileSize), thisLayer.layerZeroZero.y + 5f, thisLayer.layerZeroZero.z + (roomTileSize / 2) + ((thisLayer.layerHeight - 1) * roomTileSize)), GetSpawnRotation(90), currentLayerParent.transform);
         }
         //goInstantiated = Instantiate(randomPrefab(basicRoom), new Vector3(thisLayer.layerZeroZero.x + (i * roomTileSize), thisLayer.layerZeroZero.y, thisLayer.layerZeroZero.z + (j * roomTileSize)), GetSpawnRotation(randomPrefabRotation()), currentLayerParent.transform);
         if (!(((curGameLayer.exitWall == Direction.SOUTH) && (i == curGameLayer.exitWallLoc)) || ((curGameLayer.entranceWall == Direction.SOUTH) && (i == curGameLayer.entranceWallLoc))))
         {
             //did not find a north wall matching exit or entrance, instantiate here
             goInstantiated = Instantiate(basicBorder[0], new Vector3(thisLayer.layerZeroZero.x + (i * roomTileSize), thisLayer.layerZeroZero.y + 5f, thisLayer.layerZeroZero.z - (roomTileSize / 2)), GetSpawnRotation(90), currentLayerParent.transform);
         }
     }
     //instantiate east and west
     for (int i = 0; i < thisLayer.layerHeight; i++)
     {
         if (!(((curGameLayer.exitWall == Direction.EAST) && (i == curGameLayer.exitWallLoc)) || ((curGameLayer.entranceWall == Direction.EAST) && (i == curGameLayer.entranceWallLoc))))
         {
             //did not find a north wall matching exit or entrance, instantiate here
             goInstantiated = Instantiate(basicBorder[0], new Vector3(thisLayer.layerZeroZero.x + ((thisLayer.layerWidth - 1) * roomTileSize) + (roomTileSize / 2), thisLayer.layerZeroZero.y + 5f, thisLayer.layerZeroZero.z + (i * roomTileSize)), GetSpawnRotation(0), currentLayerParent.transform);
         }
         //goInstantiated = Instantiate(randomPrefab(basicRoom), new Vector3(thisLayer.layerZeroZero.x + (i * roomTileSize), thisLayer.layerZeroZero.y, thisLayer.layerZeroZero.z + (j * roomTileSize)), GetSpawnRotation(randomPrefabRotation()), currentLayerParent.transform);
         if (!(((curGameLayer.exitWall == Direction.WEST) && (i == curGameLayer.exitWallLoc)) || ((curGameLayer.entranceWall == Direction.WEST) && (i == curGameLayer.entranceWallLoc))))
         {
             //did not find a north wall matching exit or entrance, instantiate here
             goInstantiated = Instantiate(basicBorder[0], new Vector3(thisLayer.layerZeroZero.x - (roomTileSize / 2), thisLayer.layerZeroZero.y + 5f, thisLayer.layerZeroZero.z + (i * roomTileSize)), GetSpawnRotation(0), currentLayerParent.transform);
         }
     }
 }
Beispiel #4
0
        public static void GenerateFromCsv(string csv, SpriteMapping spriteMapping, GameLayer layer)
        {
            var spriteNames = CsvHelper.ReadCsv(csv);
            var tiles       = TransformNamesToVectors(spriteNames, spriteMapping.Width, spriteMapping.Height);

            foreach (var tile in tiles)
            {
                var tileNames  = tile.Value;
                var tileArray  = tileNames.Split(';');
                var tileName   = string.Format("Tile_{0}_{1}_{2}", tileNames, tile.Key.X, tile.Key.Y);
                var gameObject = new GameObject(tileName, tile.Key);

                var spriteName = tileArray[0];
                var sprite     = new SpriteMappingComponent(spriteMapping, spriteName);

                if (tileArray.Count() > 1)
                {
                    var blockingProperty = tileArray[1];
                    if (blockingProperty.ToUpperInvariant() == "B")
                    {
                        var boundary = new BoundaryComponent(spriteMapping.Width, spriteMapping.Height);
                        gameObject.AddComponent(boundary);
                    }
                }
                gameObject.AddComponent(sprite);
                layer.AddGameObject(gameObject);
            }
        }
Beispiel #5
0
        public void LoopGames(bool remove)
        {
            var gameLayer = new GameLayer(ApiKey);
            var games     = gameLayer.GetGames();

            foreach (var game in games)
            {
                if (!game.Active)
                {
                    continue;
                }

                Console.WriteLine($"Game :: {game.GameId}");
                Console.WriteLine($"Started = {game.Started}");
                Console.WriteLine($"StartedAt = {game.StartedAt}");

                if (remove)
                {
                    gameLayer.EndGame(game.GameId);
                    Console.WriteLine($"Ending game...");
                }

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine("Total games: " + games.Count);
            Console.WriteLine("Active games: " + games.Count(x => x.Active));
            Console.WriteLine("Started games: " + games.Count(x => x.Started));
        }
Beispiel #6
0
 public void LoadCard(CardRewardData cardData, GameLayer layer = 0x13)
 {
     this.m_layer     = layer;
     this.m_CardID    = cardData.CardID;
     this.m_cardFlair = new CardFlair(cardData.Premium);
     DefLoader.Get().LoadFullDef(this.m_CardID, new DefLoader.LoadDefCallback <FullDef>(this.OnFullDefLoaded));
 }
Beispiel #7
0
        public void LoadSpecifiedReplay()
        {
            var gameId = "ce7a97e2-e499-4b1e-9a1c-f72a35f0ac2d";

            var gameLayer = new GameLayer(ApiKey);
            var replay    = LoadReplay(gameId);
        }
		public override void ApplicationDidFinishLaunching (CCApplication application, CCWindow mainWindow)
		{
			application.PreferMultiSampling = false;
			application.ContentRootDirectory = "Content";
			application.ContentSearchPaths.Add ("animations");
			application.ContentSearchPaths.Add ("fonts");
			application.ContentSearchPaths.Add ("sounds");

			CCSize windowSize = mainWindow.WindowSizeInPixels;

			float desiredHeight = 1024.0f;
			float desiredWidth = 768.0f;
    
			// This will set the world bounds to be (0,0, w, h)
			// CCSceneResolutionPolicy.ShowAll will ensure that the aspect ratio is preserved
			CCScene.SetDefaultDesignResolution (desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll);
            
           
			CCScene scene = new CCScene (mainWindow);
			GameLayer gameLayer = new GameLayer ();

			scene.AddChild (gameLayer);

			mainWindow.RunWithScene (scene);
		}
Beispiel #9
0
        public static Turn GetBestPlaceUtilityTurn(GameLayer gameLayer)
        {
            var state = gameLayer.GetState();
            var uArr  = Helper.GetUtilitiyGrid(state);

            if (state.AvailableUtilityBuildings.Any(t => t.BuildingName == "Mall") && state.AvailableUtilityBuildings.Find(t => t.BuildingName == "Mall").ReleaseTick < state.Turn && !state.UtilityBuildings.Any(x => x.BuildingName == "Mall"))
            {
                var      bluep = gameLayer.GetUtilityBlueprint("Mall");
                Position pos   = GetBestPos(uArr, gameLayer, 3, "Mall");
                if (pos != null && state.Funds > bluep.Cost + 5000)
                {
                    return(new PlaceUtilityTurn(pos.x, pos.y, bluep, state.GameId));
                }
            }
            if (state.AvailableUtilityBuildings.Any(t => t.BuildingName == "Park") && state.AvailableUtilityBuildings.Find(t => t.BuildingName == "Park").ReleaseTick < state.Turn && !state.UtilityBuildings.Any(x => x.BuildingName == "Park"))
            {
                var      bluep = gameLayer.GetUtilityBlueprint("Park");
                Position pos   = GetBestPos(uArr, gameLayer, 2, "Park");
                if (pos != null && state.Funds > bluep.Cost + 5000)
                {
                    return(new PlaceUtilityTurn(pos.x, pos.y, bluep, state.GameId));
                }
            }
            if (state.AvailableUtilityBuildings.Any(t => t.BuildingName == "WindTurbine") && state.AvailableUtilityBuildings.Find(t => t.BuildingName == "WindTurbine").ReleaseTick < state.Turn && !state.UtilityBuildings.Any(x => x.BuildingName == "WindTurbine"))
            {
                var      bluep = gameLayer.GetUtilityBlueprint("WindTurbine");
                Position pos   = GetBestPos(uArr, gameLayer, 2, "WindTurbine");
                if (pos != null && state.Funds > bluep.Cost + 5000)
                {
                    return(new PlaceUtilityTurn(pos.x, pos.y, bluep, state.GameId));
                }
            }
            return(null);
        }
        public override void ApplicationDidFinishLaunching( CCApplication application, CCWindow mainWindow )
        {
            application.ContentRootDirectory = "Content";
            var windowSize = mainWindow.WindowSizeInPixels;

            var desiredWidth = 768.0f;
            var desiredHeight = 1024.0f;

            // This will set the world bounds to be (0,0, w, h)
            // CCSceneResolutionPolicy.ShowAll will ensure that the aspect ratio is preserved
            CCScene.SetDefaultDesignResolution( desiredWidth, desiredHeight, CCSceneResolutionPolicy.ShowAll );

            // Determine whether to use the high or low def versions of our images
            // Make sure the default texel to content size ratio is set correctly
            // Of course you're free to have a finer set of image resolutions e.g (ld, hd, super-hd)
            if( desiredWidth < windowSize.Width )
            {
                application.ContentSearchPaths.Add( "hd" );
                CCSprite.DefaultTexelToContentSizeRatio = 1.0f;
            }
            else
            {
                application.ContentSearchPaths.Add( "ld" );
                CCSprite.DefaultTexelToContentSizeRatio = 1.0f;
            }

            var scene = new CCScene( mainWindow );
            var gameLayer = new GameLayer();

            scene.AddChild( gameLayer );

            mainWindow.RunWithScene( scene );
        }
Beispiel #11
0
    private Vector3 getExitPosition(GameLayer thisLayer)
    {
        Vector3 layerExitPos = new Vector3(0, roomTileHeight - (roomTileHeight * thisLayer.thisLayerNumber), 0);

        switch (thisLayer.exitWall)
        {
        case Direction.NORTH:
            layerExitPos.x = thisLayer.layerZeroZero.x + (roomTileSize * thisLayer.exitWallLoc);
            layerExitPos.z = thisLayer.layerZeroZero.z + (roomTileSize * thisLayer.layerHeight);
            break;

        case Direction.SOUTH:
            layerExitPos.x = thisLayer.layerZeroZero.x + (roomTileSize * thisLayer.exitWallLoc);
            layerExitPos.z = thisLayer.layerZeroZero.z - (roomTileSize);
            break;

        case Direction.EAST:
            layerExitPos.x = thisLayer.layerZeroZero.x + (roomTileSize * thisLayer.layerWidth);
            layerExitPos.z = thisLayer.layerZeroZero.z + (roomTileSize * thisLayer.exitWallLoc);
            break;

        case Direction.WEST:
            layerExitPos.x = thisLayer.layerZeroZero.x - (roomTileSize);
            layerExitPos.z = thisLayer.layerZeroZero.z + (roomTileSize * thisLayer.exitWallLoc);
            break;
        }

        return(layerExitPos);
    }
Beispiel #12
0
    private Vector3 findLayerZeroZero(GameLayer thisLayer)
    {
        Vector3 layerZeroZero = new Vector3(0, roomTileHeight - (roomTileHeight * thisLayer.thisLayerNumber), 0);

        switch (thisLayer.entranceWall)
        {
        case Direction.NORTH:
            layerZeroZero.x = thisLayer.entrancePos.x - (roomTileSize * thisLayer.entranceWallLoc);
            layerZeroZero.z = (thisLayer.entrancePos.z) - (roomTileSize * thisLayer.layerHeight);
//                Debug.Log("x " + layerZeroZero.x + " :: " + layerZeroZero.y + " :: " + layerZeroZero.z);
            break;

        case Direction.SOUTH:
            layerZeroZero.x = thisLayer.entrancePos.x - (roomTileSize * thisLayer.entranceWallLoc);
            layerZeroZero.z = (thisLayer.entrancePos.z) + (roomTileSize);
            break;

        case Direction.EAST:
            layerZeroZero.x = thisLayer.entrancePos.x - (roomTileSize * thisLayer.layerWidth);
            layerZeroZero.z = (thisLayer.entrancePos.z) - (roomTileSize * thisLayer.entranceWallLoc);
            break;

        case Direction.WEST:
            layerZeroZero.x = thisLayer.entrancePos.x + (roomTileSize);
            layerZeroZero.z = (thisLayer.entrancePos.z) - (roomTileSize * thisLayer.entranceWallLoc);
            break;
        }


        return(layerZeroZero);
    }
    private void CreateHitTestPriorityMap()
    {
        this.m_hitTestPriorityMap = new Map <GameLayer, int>();
        int num = 1;

        for (int i = 0; i < HIT_TEST_PRIORITY_ORDER.Length; i++)
        {
            GameLayer key = HIT_TEST_PRIORITY_ORDER[i];
            this.m_hitTestPriorityMap.Add(key, num++);
        }
        IEnumerator enumerator = Enum.GetValues(typeof(GameLayer)).GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                GameLayer current = (GameLayer)((int)enumerator.Current);
                if (!this.m_hitTestPriorityMap.ContainsKey(current))
                {
                    this.m_hitTestPriorityMap.Add(current, 0);
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable == null)
            {
            }
            disposable.Dispose();
        }
    }
        internal static Bundle GetBestUpgradeTurn(Upgrade upgrade, GameLayer layer)
        {
            switch (upgrade.Name)
            {
            case "Caretaker":
                return(GetBestCaretaker(upgrade, layer));

            case "Charger":
                return(GetBestCharger(upgrade, layer));

            case "SolarPanel":
                return(GetBestSolarPanel(upgrade, layer));

            case "Insulation":
                return(GetBestInsulation(upgrade, layer));

            case "Playground":
                return(GetBestPlayground(upgrade, layer));

            case "Regulator":
                return(GetBestRegulator(upgrade, layer));

            default:
                return(null);
            }
        }
Beispiel #15
0
    public void OnGenerateNextLayer()
    {
        //goInstantiated = Instantiate(randomPrefab(basicRoom), new Vector3(0f,0f,0f), GetSpawnRotation(randomPrefabRotation()));



        curGameLayer = gameLayers[GameManager.Instance.getCurrentLayer()];
        curGameLayer.thisLayerNumber = GameManager.Instance.getCurrentLayer() + 1;
        //instantiate parent for layer contents
        currentLayerParent = new GameObject("Layer" + curGameLayer.thisLayerNumber);
        //currentLayerParent = Instantiate(new GameObject(), new Vector3(0f, 0f, 0f), Quaternion.identity, layerRootGO.transform);
        currentLayerParent.transform.parent = layerRootGO.transform;

        //check for end of prebuilt levels
        if (curGameLayer.thisLayerNumber >= gameLayers.Count)
        {
            GameLayer depthLayer = getDepthLayer(curGameLayer.thisLayerNumber);
            gameLayers.Add(depthLayer);
        }

        curGameLayer.entranceWallLoc = findEntranceLoc(curGameLayer);
        curGameLayer.exitWall        = findExitEdge(curGameLayer);
        curGameLayer.exitWallLoc     = findExitLoc(curGameLayer);
        curGameLayer.layerZeroZero   = findLayerZeroZero(curGameLayer);
        instantiateRooms(curGameLayer);
        //
        instantiateBorder(curGameLayer);
        curGameLayer.exitPos        = getExitPosition(curGameLayer);
        curGameLayer.exitLockNeeded = calculateExitNeededFromLayer(curGameLayer.thisLayerNumber);
        placeExit(curGameLayer);
    }
        private static Bundle GetBestPlayground(Upgrade upgrade, GameLayer layer)
        {
            var      state = layer.GetState();
            Position pos   = new Position(0, 0);
            BuiltResidenceBuilding building = null;
            int turnsleft   = state.MaxTurns - state.Turn;
            int popAffected = 0;

            foreach (var build in state.ResidenceBuildings)
            {
                if (!build.Effects.Contains(upgrade.Name) && popAffected < layer.GetResidenceBlueprint(build.BuildingName).MaxPop)
                {
                    building    = build;
                    popAffected = layer.GetResidenceBlueprint(build.BuildingName).MaxPop;
                    pos         = build.Position;
                }
            }
            if (building == null)
            {
                return(null);
            }
            var b = new Bundle
            {
                EnergyNeed     = 0,
                ExtraCost      = 0,
                PotentialScore = popAffected * turnsleft * 0.16 / 10 + 0.007 * popAffected * turnsleft,
                TotalIncome    = 0,
                Turn           = new UpgradeTurn(pos.x, pos.y, upgrade.Name, state.GameId),
                UpfrontCost    = 5200
            };

            return(b);
        }
        private static Bundle GetBestCaretaker(Upgrade upgrade, GameLayer layer)
        {
            var      state = layer.GetState();
            Position pos   = new Position(0, 0);
            BuiltResidenceBuilding building = null;
            int    turnsleft = state.MaxTurns - state.Turn;
            double save      = 0;

            foreach (var build in state.ResidenceBuildings)
            {
                double maintCost = layer.GetResidenceBlueprint(build.BuildingName).MaintenanceCost;
                double decayRate = layer.GetResidenceBlueprint(build.BuildingName).DecayRate + build.Effects.Where(t => t == "Charger" || t == "Regulator" || t == "Playground" || t == "SolarPanel" || t == "Insulation").Count() * 0.2;
                if (!build.Effects.Contains(upgrade.Name) && save < maintCost * Math.Ceiling(turnsleft / (55 / decayRate)) - maintCost * Math.Ceiling(turnsleft * 0.25 / (55 / decayRate)) - 6 * turnsleft - 3500)
                {
                    building = build;
                    pos      = build.Position;
                    save     = maintCost * Math.Ceiling(turnsleft / (55 / decayRate)) - maintCost * Math.Ceiling(turnsleft * 0.25 / (55 / decayRate)) - 6 * turnsleft - 3500;
                }
            }
            if (building == null)
            {
                return(null);
            }
            var b = new Bundle
            {
                EnergyNeed     = 0,
                ExtraCost      = 6 * turnsleft,
                PotentialScore = 0,
                TotalIncome    = save + 6 * turnsleft + 3500,
                Turn           = new UpgradeTurn(pos.x, pos.y, upgrade.Name, state.GameId),
                UpfrontCost    = 3500
            };

            return(b);
        }
    public static void ReplaceLayer(GameObject parentObject, GameLayer newLayer, GameLayer oldLayer)
    {
        if (parentObject.layer == oldLayer)
        {
            parentObject.layer = (int)newLayer;
        }
        IEnumerator enumerator = parentObject.transform.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                Transform current = (Transform)enumerator.Current;
                if (current.gameObject.layer == oldLayer)
                {
                    SetLayer(current.gameObject, newLayer);
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable == null)
            {
            }
            disposable.Dispose();
        }
    }
    private bool HigherPriorityCollisionExists(GameLayer layer)
    {
        if (this.m_systemDialogActive && (this.m_hitTestPriorityMap[layer] < this.m_hitTestPriorityMap[GameLayer.UI]))
        {
            return(true);
        }
        if (this.m_gameDialogActive && (this.m_hitTestPriorityMap[layer] < this.m_hitTestPriorityMap[GameLayer.IgnoreFullScreenEffects]))
        {
            return(true);
        }
        if (this.m_FullscreenEffectsCameraActive && (this.m_hitTestPriorityMap[layer] < this.m_hitTestPriorityMap[GameLayer.IgnoreFullScreenEffects]))
        {
            return(true);
        }
        LayerMask higherPriorityLayerMask = this.GetHigherPriorityLayerMask(layer);

        foreach (Camera camera in Camera.allCameras)
        {
            RaycastHit hit;
            if ((!this.m_ignoredCameras.Contains(camera) && ((camera.cullingMask & higherPriorityLayerMask) != 0)) && this.FilteredRaycast(camera, this.GetMousePosition(), higherPriorityLayerMask, out hit))
            {
                GameLayer gameLayer = (GameLayer)hit.collider.gameObject.layer;
                if ((camera.cullingMask & gameLayer.LayerBit()) != 0)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Beispiel #20
0
        protected override void OnRegistered()
        {
            int width = Program.ObjWidth;

            GameLayer.AddObject(new Goal(new asd.Vector2DF(23 * width, 16 * width)));
            Random r    = new Random();
            Random rand = new Random();

            //重複なし乱数配列生成
            int[] array = new int[16];
            for (int i = 0; i < 16; i++)
            {
                array[i] = i;
            }
            for (int i = 0; i < 16; i++)
            {
                int x = r.Next(16);
                int t = array[i];
                array[i] = array[x];
                array[x] = t;
            }
            for (int i = 2; i < 23; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    int p = rand.Next(10);
                    if (p == 0)
                    {
                        GameLayer.AddObject(new EnemyYellow(new asd.Vector2DF(width * i, width * array[j] + width)));
                    }
                    if (p == 1)
                    {
                        GameLayer.AddObject(new EnemyRed(new asd.Vector2DF(width * i, width * array[j] + width)));
                    }
                    if (p == 2)
                    {
                        GameLayer.AddObject(new WhiteWall(new asd.Vector2DF(width * i, width * array[j] + width)));
                    }
                    if (p == 3)
                    {
                        ; GameLayer.AddObject(new YellowWall(new asd.Vector2DF(width * i, width * array[j] + width)));
                    }
                    if (p == 4)
                    {
                        GameLayer.AddObject(new WhiteWall(new asd.Vector2DF(width * i, width * array[j] + width)));
                    }
                    if (p == 5)
                    {
                        GameLayer.AddObject(new EnemyWhite(new asd.Vector2DF(width * i, width * array[j] + width)));
                    }
                    else
                    {
                        //何も作らない
                    }
                }
            }
            GameLayer.AddObject(new Explain(new asd.Vector2DF(Program.WindowSizeX - Program.ObjWidth * 3.5f, Program.WindowSizeY / 2)));
            GameLayer.AddObject(new Player(new asd.Vector2DF(width, 10 * width)));
        }
        private static Bundle GetBestInsulation(Upgrade upgrade, GameLayer layer)
        {
            var      state = layer.GetState();
            Position pos   = new Position(0, 0);
            BuiltResidenceBuilding building = null;

            return(null);
        }
Beispiel #22
0
 public AsteroidManager(Texture2D[] textures, Texture2D[] deathTextures, GameLayer gameLayer)
 {
     _texture2D     = textures;
     _deathTextures = deathTextures;
     _lastTimeSpan  = new TimeSpan();
     _random        = new Random();
     _gameLayer     = gameLayer;
 }
Beispiel #23
0
 public static void SetLayer(GameObject g, GameLayer l)
 {
     g.layer = (int)l;
     foreach (Transform t in g.transform)
     {
         SetLayer(t.gameObject, l);
     }
 }
 private void MoveToActiveLayer(bool saveOriginalLayer)
 {
     if (saveOriginalLayer)
     {
         this.m_originalLayer = (GameLayer)base.gameObject.layer;
     }
     SceneUtils.SetLayer(base.gameObject, this.m_activeLayer);
 }
Beispiel #25
0
 private static double GetNextTemp(BuiltResidenceBuilding building, GameLayer gameLayer)
 {
     return
         (building.Temperature +
          (building.EffectiveEnergyIn - gameLayer.GetResidenceBlueprint(building.BuildingName).BaseEnergyNeed) * Constants.DEGREES_PER_EXCESS_MWH +
          Constants.DEGREES_PER_POP * building.CurrentPop -
          (building.Temperature - gameLayer.GetState().CurrentTemp) * (gameLayer.GetResidenceBlueprint(building.BuildingName).Emissivity *(building.Effects.Contains("Insulation") ? 0.6 : 1)));
 }
Beispiel #26
0
        public void Update(float ms)
        {
            UpdateAliens(ms);

            UpdateWeaponDepots(ms);
            if (currentSection < sections.Count - 1)
            {
                if (sections[currentSection].GetAlienCount() == 0)
                {
                    sections[currentSection].Open();
                    currentSection += 1;
                    sections[currentSection].FillWithAliens();

                    // respawn
                    if (Globals.gameInstance.players.Length > 1)
                    {
                        if (!Globals.gameInstance.players[0].alive)
                        {
                            Globals.gameInstance.players[0].Respawn(Globals.gameInstance.players[1].Position);
                        }
                        else if (!Globals.gameInstance.players[1].alive)
                        {
                            Globals.gameInstance.players[1].Respawn(Globals.gameInstance.players[0].Position);
                        }
                    }
                }
            }
            else
            {
                // check if players are both on the portal
                bool allOnPortal = true;
                for (int i = 0; i < Globals.gameInstance.players.Length; i++)
                {
                    if (Vector3.DistanceSquared(endteleporter.Position, Globals.gameInstance.players[i].Position) > 1.5f)
                    {
                        allOnPortal = false;
                        break;
                    }
                }

                if (allOnPortal && !endteleporter.Started && !endteleporter.Finished)
                {
                    endteleporter.Start();
                }
                endteleporter.Update(ms);

                if (endteleporter.Progress > 30)
                {
                    // win
                    //Globals.gameInstance.parentLayer.
                    GameLayer game = (GameLayer)Globals.screenManager.GetTop();
                    game.fadeOutCompleteCallback = win;
                    game.StartTransitionOff();
                }
            }

            UpdateDoors(ms);
        }
Beispiel #27
0
    public virtual void Init()
    {
        isActive  = false;
        isGoExcit = false;
        name      = this.GetType().Name;
        ViewManager.Regist(this);

        this.layer = GameLayer.Wnd;
    }
Beispiel #28
0
        public static CCScene GameScene(GameLayer sender, CCWindow window, CardBase[] cards)
        {
            var scene = new CCScene(window);
            var layer = new ChooseCardLayer(sender, cards);

            scene.AddChild(layer);

            return(scene);
        }
Beispiel #29
0
 public override Turn TakeTurn(GameLayer gameLayer)
 {
     gameLayer.Wait(_gameId);
     if (_nextTurn != null)
     {
         Program.StackedTurns.Push(_nextTurn);
     }
     return(null);
 }
Beispiel #30
0
        public GameTouchHandler(GameLayer gameLayer, HexMexCamera hexMexCamera)
        {
            GameLayer    = gameLayer;
            HexMexCamera = hexMexCamera;
            var eventListener = new CCEventListenerTouchOneByOne {
                IsEnabled = true, OnTouchBegan = OnTouchBegan, OnTouchCancelled = OnTouchCancelled, OnTouchEnded = OnTouchEnded, OnTouchMoved = OnTouchMoved
            };

            gameLayer.AddEventListener(eventListener);
        }
Beispiel #31
0
        public static int GetCurrentMaxPop(GameLayer layer)
        {
            int ret = 0;

            foreach (var build in layer.GetState().ResidenceBuildings)
            {
                ret += layer.GetResidenceBlueprint(build.BuildingName).MaxPop;
            }
            return(ret);
        }
 public Color GetColor(GameLayer layer)
 {
     if (_path == null) {
         _path = FindObjectOfType<Path>();
     }
     float sat = MathHelpers.LinMapFrom01(_saturationRange.Min, _saturationRange.Max, _saturationCurve.Evaluate(_path.CurrFraction));
     var color = HSBColor.FromColor(_startColors[(int)layer]);
     color.s = sat;
     return color.ToColor();
 }
Beispiel #33
0
 private void instantiateRooms(GameLayer thisLayer)
 {
     for (int j = 0; j < thisLayer.layerHeight; j++)
     {
         for (int i = 0; i < thisLayer.layerWidth; i++)
         {
             goInstantiated = Instantiate(randomPrefab(basicRoom), new Vector3(thisLayer.layerZeroZero.x + (i * roomTileSize), thisLayer.layerZeroZero.y, thisLayer.layerZeroZero.z + (j * roomTileSize)), GetSpawnRotation(randomPrefabRotation()), currentLayerParent.transform);
         }
     }
 }
        public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow)
        {
            application.PreferMultiSampling = false;
            application.ContentRootDirectory = "Content";
            application.ContentSearchPaths.Add("animations");
            application.ContentSearchPaths.Add("fonts");
            application.ContentSearchPaths.Add("sounds");

            CCSize windowSize = mainWindow.WindowSizeInPixels;

            float desiredWidth = 1024.0f;
            float desiredHeight = 768.0f;
            
            // This will set the world bounds to be (0,0, w, h)
            // Use CCSceneResolutionPolicy.Custom as we're manually setting our viewports
            CCScene.SetDefaultDesignResolution(desiredWidth, desiredHeight, CCSceneResolutionPolicy.Custom);
            
            // Determine whether to use the high or low def versions of our images
            // Make sure the default texel to content size ratio is set correctly
            // Of course you're free to have a finer set of image resolutions e.g (ld, hd, super-hd)
            if (desiredWidth < windowSize.Width)
            {
                application.ContentSearchPaths.Add("images/hd");
                CCSprite.DefaultTexelToContentSizeRatio = 2.0f;
            }
            else
            {
                application.ContentSearchPaths.Add("images/ld");
                CCSprite.DefaultTexelToContentSizeRatio = 1.0f;
            }
            
            var topViewport = new CCViewport(new CCRect(0.0f, 0.2f, .5f, 0.6f));
            var bottomViewport = new CCViewport(new CCRect(0.5f, 0.0f, .5f, 1.0f));

            // Each viewport needs its own director
            var sceneDirector1 = new CCDirector();
            var sceneDirector2 = new CCDirector();

            var scene1 = new CCScene(mainWindow, topViewport, sceneDirector1);
            var scene2 = new CCScene(mainWindow, bottomViewport, sceneDirector2);

            var layer1 = new GameLayer();
            var layer2 = new GameLayer();

            scene1.AddChild(layer1);
            scene2.AddChild(layer2);

            sceneDirector1.RunWithScene(scene1);
            sceneDirector2.RunWithScene(scene2);
        }
 static UniversalInputManager()
 {
     GameLayer[] gameLayerArray = new GameLayer[11];
     int index1 = 0;
     int num1 = 13;
     gameLayerArray[index1] = (GameLayer) num1;
     int index2 = 1;
     int num2 = 16;
     gameLayerArray[index2] = (GameLayer) num2;
     int index3 = 2;
     int num3 = 19;
     gameLayerArray[index3] = (GameLayer) num3;
     int index4 = 3;
     int num4 = 27;
     gameLayerArray[index4] = (GameLayer) num4;
     int index5 = 4;
     int num5 = 31;
     gameLayerArray[index5] = (GameLayer) num5;
     int index6 = 5;
     int num6 = 18;
     gameLayerArray[index6] = (GameLayer) num6;
     int index7 = 6;
     int num7 = 24;
     gameLayerArray[index7] = (GameLayer) num7;
     int index8 = 7;
     int num8 = 25;
     gameLayerArray[index8] = (GameLayer) num8;
     int index9 = 8;
     int num9 = 26;
     gameLayerArray[index9] = (GameLayer) num9;
     int index10 = 9;
     int num10 = 29;
     gameLayerArray[index10] = (GameLayer) num10;
     int index11 = 10;
     int num11 = 17;
     gameLayerArray[index11] = (GameLayer) num11;
     //UniversalInputManager.HIT_TEST_PRIORITY_ORDER = gameLayerArray;
     UniversalInputManager.IsIMEEverUsed = false;
     UniversalInputManager.UsePhoneUI = new PlatformDependentValue<bool>(PlatformCategory.Screen)
     {
       Phone = true,
       Tablet = false,
       PC = false
     };
 }
        public GameScene(CCWindow window) : base(window) {
            Id = "";

            _backgroundLayer = new BackgroundLayer();
            AddChild(_backgroundLayer);

            var cameraVisibleBounds = new CCSize(Settings.ScreenWidth, Settings.ScreenHeight);
            var camera = new CCCamera(CCCameraProjection.Projection3D, cameraVisibleBounds,
                new CCPoint3(Settings.ScreenWidth, Settings.ScreenHeight, 10));

            GameLayer = new GameLayer {
                Tag = Tags.Client,
                Camera = camera,
            };
            AddChild(GameLayer);

            _chatLayer = new ChatLayer();
            AddChild(_chatLayer);

            _hudLayer = new HudLayer();
            AddChild(_hudLayer);


            var keyListener = new CCEventListenerKeyboard {OnKeyPressed = OnKeyPressed, OnKeyReleased = OnKeyReleased};
            AddEventListener(keyListener, this);

            var mouseListener = new CCEventListenerMouse {
                OnMouseDown = OnMouseDown,
                OnMouseUp = OnMouseUp,
                OnMouseMove = OnMouseScroll
            };
            AddEventListener(mouseListener, this);

            var parser = new FileIniDataParser();
            IniData data = parser.ReadFile("Config.ini");
            string nickname = data["Client"]["nickname"];
            _netGameClient = new NetGameClient(data["Server"]["ip"], this);
            _netGameClient.ConnectToServer(nickname);

            InitEvents();

            Schedule(Update);
            Schedule(UpdateNetwork, Settings.NetworkFreqUpdate);
        }
        public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow)
        {

            CCLog.Logger = System.Diagnostics.Debug.WriteLine;
                
            application.PreferMultiSampling = true;

            application.ContentRootDirectory = "Content";
           
            CCSize windowSize = mainWindow.WindowSizeInPixels;

            float desiredWidth = 1024.0f;
            float desiredHeight = 768.0f;

            desiredWidth = windowSize.Width;
            desiredHeight = windowSize.Height;

            // This will set the world bounds to be (0,0, w, h)
            // CCSceneResolutionPolicy.ShowAll will ensure that the aspect ratio is preserved
            CCScene.SetDefaultDesignResolution(desiredWidth, desiredHeight, CCSceneResolutionPolicy.ExactFit);
            
            // Determine whether to use the high or low def versions of our images
            // Make sure the default texel to content size ratio is set correctly
            // Of course you're free to have a finer set of image resolutions e.g (ld, hd, super-hd)
            if (desiredWidth < windowSize.Width)
            {
                application.ContentSearchPaths.Add("images/hd");
                CCSprite.DefaultTexelToContentSizeRatio = 2.0f;
            }
            else
            {
                application.ContentSearchPaths.Add("images/ld");
                CCSprite.DefaultTexelToContentSizeRatio = 1.0f;
            }
            
            CCScene scene = new CCScene(mainWindow);
            GameLayer gameLayer = new GameLayer();

            scene.AddChild(gameLayer);

            mainWindow.RunWithScene(scene);
        }
        public ServerScene(CCWindow window) : base(window) {
            LocationsDict = new Dictionary<Locations, GameLayer>();

            _gameLayer = new GameLayer {Tag = Tags.Server, Location = Locations.Desert};
            AddChild(_gameLayer);
            LocationsDict.Add(Locations.Desert, _gameLayer);

            _townGameLayer = new GameLayer {Tag = Tags.Server, Location = Locations.Town};
            AddChild(_townGameLayer);
            LocationsDict.Add(Locations.Town, _townGameLayer);

            _cityGameLayer = new GameLayer {Tag = Tags.Server, Location = Locations.City};
            AddChild(_cityGameLayer);
            LocationsDict.Add(Locations.City, _cityGameLayer);


            _caveGameLayer = new GameLayer {Tag = Tags.Server, Location = Locations.Cave};
            AddChild(_caveGameLayer);
            LocationsDict.Add(Locations.Cave, _caveGameLayer);

            Log.Print("Game has started, waiting for players");
            Schedule(UpdateNetwork, Settings.NetworkFreqUpdate);
            Schedule(UpdateLogic);
        }
 public static void FindAllByLayer(GameLayer layer, List<Camera> cameras)
 {
     CameraUtils.FindAllByLayerMask((LayerMask) GameLayerExtensions.LayerBit(layer), cameras);
 }
Beispiel #40
0
        public static CCScene GameScene(CCWindow mainWindow)
        {
            var scene = new CCScene (mainWindow);
            var layer = new GameLayer ();

            scene.AddChild (layer);

            return scene;
        }
 public static Camera FindFirstByLayer(GameLayer layer)
 {
     return CameraUtils.FindFirstByLayerMask((LayerMask) GameLayerExtensions.LayerBit(layer));
 }
 public void EnableHitTestOffCamera(GameLayer layer, bool enable)
 {
     this.EnableHitTestOffCamera((LayerMask) GameLayerExtensions.LayerBit(layer), enable);
 }
 public bool GetInputHitInfo(GameLayer layer, out RaycastHit hitInfo)
 {
     return this.GetInputHitInfo((LayerMask) GameLayerExtensions.LayerBit(layer), out hitInfo);
 }
 public bool InputHitAnyObject(Camera requestedCamera, GameLayer layer)
 {
     RaycastHit hitInfo;
     return this.GetInputHitInfo(requestedCamera, layer, out hitInfo);
 }
 public bool CanHitTestOffCamera(GameLayer layer)
 {
     return this.CanHitTestOffCamera((LayerMask) GameLayerExtensions.LayerBit(layer));
 }
Beispiel #46
0
    public int CheatNextSampleToSwapOn(GameLayer objectOnLayer)
    {
        int advanceSamples = Random.Range(_cheatAdvanceSamplesRange.Min, _cheatAdvanceSamplesRange.Max);
        for (int index = _currentObstacleIndex; index < _obstacles.Length; index++) {
            if (_obstacles[index].Layer != objectOnLayer) {
                return _obstacles[index].StartSample - advanceSamples;
            }
        }

        return _audioSource.clip.samples + 1; // Never swap if no more obstacles
    }
Beispiel #47
0
 public bool IsCurrentlyBlocked(GameLayer objectOnLayer)
 {
     if (_currentObstacleIndex <= _obstacles.Length-1) {
         bool withinObstacle = _obstacles[_currentObstacleIndex].StartSample <= CurrentSample && _obstacles[_currentObstacleIndex].StopSample >= CurrentSample;
         return _obstacles[_currentObstacleIndex].Layer != objectOnLayer && withinObstacle;
     }
     return false;
 }
        public static CCScene GameScene(CCWindow mainWindow)
        {
            var scene = new CCScene (mainWindow);

            float w_baseline = 640.0f;
            float h_baseline = 1136.0f;

            CCSize winSize = mainWindow.WindowSizeInPixels;

            var layer = new GameLayer (winSize.Width / w_baseline, winSize.Height / h_baseline);

            scene.AddChild (layer);

            return scene;
        }
 public bool GetInputHitInfo(Camera requestedCamera, GameLayer layer, out RaycastHit hitInfo)
 {
     Camera camera;
     return this.Raycast(requestedCamera, (LayerMask) GameLayerExtensions.LayerBit(layer), out camera, out hitInfo, false);
 }
 public bool GetInputPointOnPlane(GameLayer layer, Vector3 origin, out Vector3 point)
 {
     point = Vector3.zero;
     Camera camera;
     RaycastHit hitInfo;
     if (!this.Raycast((Camera) null, (LayerMask) GameLayerExtensions.LayerBit(layer), out camera, out hitInfo, false))
       return false;
     Ray ray = camera.ScreenPointToRay(this.GetMousePosition());
     float enter;
     if (!new Plane(-camera.transform.forward, origin).Raycast(ray, out enter))
       return false;
     point = ray.GetPoint(enter);
     return true;
 }
 private bool HigherPriorityCollisionExists(GameLayer layer)
 {
     if (this.m_systemDialogActive && this.m_hitTestPriorityMap[layer] < this.m_hitTestPriorityMap[GameLayer.SystemDialog] || this.m_gameDialogActive && this.m_hitTestPriorityMap[layer] < this.m_hitTestPriorityMap[GameLayer.GameDialog] || this.m_FullscreenEffectsCameraActive && this.m_hitTestPriorityMap[layer] < this.m_hitTestPriorityMap[GameLayer.IgnoreFullScreenEffects])
       return true;
     LayerMask priorityLayerMask = this.GetHigherPriorityLayerMask(layer);
     foreach (Camera camera in Camera.allCameras)
     {
       RaycastHit hitInfo;
       if (!this.m_ignoredCameras.Contains(camera) && (camera.cullingMask & (int) priorityLayerMask) != 0 && this.FilteredRaycast(camera, this.GetMousePosition(), priorityLayerMask, out hitInfo))
       {
     GameLayer gameLayer = (GameLayer) hitInfo.collider.gameObject.layer;
     if ((camera.cullingMask & GameLayerExtensions.LayerBit(gameLayer)) != 0)
       return true;
       }
     }
     return false;
 }
 private LayerMask GetHigherPriorityLayerMask(GameLayer layer)
 {
     int num = this.m_hitTestPriorityMap[layer];
     LayerMask layerMask = (LayerMask) 0;
     using (Map<GameLayer, int>.Enumerator enumerator = this.m_hitTestPriorityMap.GetEnumerator())
     {
       while (enumerator.MoveNext())
       {
     KeyValuePair<GameLayer, int> current = enumerator.Current;
     GameLayer key = current.Key;
     if (current.Value > num)
       layerMask = (LayerMask) ((int) layerMask | GameLayerExtensions.LayerBit(key));
       }
     }
     return layerMask;
 }
Beispiel #53
0
 public void SwapLayer()
 {
     _currentLayer = (GameLayer)(((int)_currentLayer+1)%System.Enum.GetNames(typeof(GameLayer)).Length);
 }
 public Material GetMaterial(GameLayer layer)
 {
     return _mainMaterials[(int)layer];
 }
 public EnemyManager(GameLayer gameLayer) {
     _gameLayer = gameLayer;
     SpawnBoss();
 }
Beispiel #56
0
 public Obstacle(int startSample, int stopSample, GameLayer layer)
 {
     StartSample = startSample;
     StopSample = stopSample;
     Layer = layer;
 }
 public bool InputHitAnyObject(GameLayer layer)
 {
     RaycastHit hitInfo;
     return this.GetInputHitInfo(layer, out hitInfo);
 }