Exemple #1
0
 private void Awake()
 {
     if (instance != this)
     {
         DestroyImmediate(instance);
     }
     instance    = this;
     oldPosition = Camera.main.transform.position;
 }
Exemple #2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
 }
 // Start is called before the first frame update
 void Start()
 {
     _timer        = 100;
     _shake        = GameObject.Find("Main Camera").GetComponent <ShakeScreen>();
     _spawnManager = GameObject.Find("Spawn Manager").GetComponent <SpawnManager>();
     if (_spawnManager == null)
     {
         Debug.LogError("The Spawn Manager in Player is NULL.");
     }
     _uiManager = GameObject.Find("Canvas").GetComponent <UIManager>();
     if (_uiManager == null)
     {
         Debug.Log("The UI Manager in Player is NULL");
     }
     _audioSource = GameObject.Find("Audio Manager").GetComponent <AudioSource>();
     if (_audioSource == null)
     {
         Debug.LogError("AudioSource in Player is NULL");
     }
 }
        public override void UpdateFixed(float step_time)
        {
            Listener.Position = new Vector3f(player.Bounds.center.X, player.Bounds.center.Y, 5.0f);

            UpdatePlayerInput();



            // old: gameActions.Dequeue().Invoke()
            Task.Factory.StartNew(() => {
                while (gameActions.Count > 0)
                {
                    gameActions.Dequeue().Invoke();
                }
            });



            ShakeScreen.Update();

            player.Update(step_time);

            entityPool.Update(step_time);


            /*
             * if (cCollision.IsPointInsideBox(player.Position, gameWorld.LevelEndRegion))
             * {
             *  //vége a pályának
             * }
             */

            this.particleManager.Update(step_time);
            effectSystem.Update();

            Vector2f playerCenter = player.Bounds.center;

            this.camera.Update(playerCenter + ShakeScreen.Offset, gameWorld.WorldBounds);

            // worldEnvironment.Update(step_time);
        }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        shakeScreenObj = GameObject.Find("Main Camera");
        shakeScreenScript = shakeScreenObj.GetComponent<ShakeScreen>();

        attackAudioObj = GameObject.Find("AttackAudios");
        attackAudioScript = attackAudioObj.GetComponent<attackAudio>();

        scoreObj = GameObject.Find("Kill");
        scoreScript = scoreObj.GetComponent<ScoreManager>();
    }
Exemple #6
0
 public void InitilizeShakeScreen()
 {
     follow = mainCamera.GetComponent <Follow>();
     ss     = mainCamera.GetComponent <ShakeScreen>();
 }
Exemple #7
0
        public override void Kill(cGameObject by)
        {
            this.Scene.LightMap.remove(this.p_followLight);
            this.Scene.LightMap.remove(this.eye);
            // this.spriteControl.ChangeState(new cSpriteState(MotionType.LIE, this.spriteControl.getCurrentState().HorizontalFacing));

            this.health = 0;
            this.killed = true;

            // int y = AppRandom.Choose<int>(new[] { 1,-1});

            this.Scene.QueueAction(() =>
            {
                Vector2f emitDirection = AppMath.Vec2NormalizeReturn(by.Velocity); //  new Vector2f(0.0f, y);

                float len   = (float)AppMath.Vec2Length(this.Velocity);
                float speed = len > 1.0f ? len : 0.0f;


                ShakeScreen.Init(this.pscene.Camera.ActualPosition);
                ShakeScreen.StartShake();


                Scene.Assets.PlaySound("blood_hit2", 25, this.position);
                //pscene.ParticleManager.Fireworks.NormalExplosion(new Particles.cEmissionInfo(this.Bounds.center, emitDirection));
                var e = pscene.ParticleManager["explosions"] as cExplosionController;
                e.NormalBlood(new EmissionInfo(this.Bounds.center, emitDirection, speed));

                e.Line(new EmissionInfo(this.Bounds.center, emitDirection));

                this.Scene.QueueAction(() =>
                {
                    /*
                     * if (this.IsOnGround)
                     * {
                     *  this.Scene.Effects.PlaceGround(this.Bounds.center.X, this.Bounds.rightBottom.Y, "side-explosion1");
                     * }
                     * else
                     */
                    {
                        this.Scene.Effects.Place(this.Bounds.center, "simple-explosion3");     // flash-black
                    }



                    // this.Scene.Effects.Place(intersection, "fire1");
                });

                // e.FastBlood(new EmissionInfo(this.Bounds.center,new Vector2f(0.0f, 0.0f)));

                //float gy = this.Bounds.rightBottom.Y; // ground y

                //pscene.Effects.PlaceGround(this.Bounds.center.X, gy, "side-explosion1");

                //pscene.EntityPool.getEntitiesInRadius()
                // pscene.Effects.Place(this.bounds.center, "simple-explosion2");
            }

                                   );

            this.Scene.QueueAction(() =>
            {
                Scene.Assets.PlaySound("coin_drop1", 20);

                ProbabilityRoll <int> numPickables = new ProbabilityRoll <int>();
                numPickables.add(70, 2);
                numPickables.add(30, 3);

                int num = numPickables.roll();
                for (int i = 0; i < num; ++i)
                {
                    pscene.EntityPool.AddPickup(
                        new cPickupAble(
                            this.Scene,
                            this.Bounds.center,
                            AppMath.GetRandomUnitVec(),                     // emitDirection,
                            PickupInfo.PickupType.COIN_GOLD)
                        );
                }
            });

            /*
             * new platformerGame.GameCommands.comPlacePickup(
             *  this.Scene,
             *  new GameObjects.cPickupAble(
             *      this.Scene,
             *      this.Scene.EntityPool.SpatialGrid,
             *      this.Bounds.center,
             *      emitDirection) )
             */
        }
Exemple #8
0
    // Use this for initialization
    void Start()
    {
        animationTest = this.GetComponent<SkeletonAnimation>();

        m_transform = this.transform;

        gameOverObj = GameObject.Find("GameOver");
        gameOverScript = gameOverObj.GetComponent<GameOver>();

        furyBarObj = GameObject.Find("FuryBar");
        furyBarScript = furyBarObj.GetComponent<FuryBarManager>();

        enemyManagerObj = GameObject.Find("EnemyCreator");
        enemyManagerScript = enemyManagerObj.GetComponent<EnemyManager>();

        //mainScreenObj = GameObject.Find("MainCamera");
        shakeScreenScript = mainScreenObj.GetComponent<ShakeScreen>();

        attackAudioObj = GameObject.Find("AttackAudios");
        attackAudioScript = attackAudioObj.GetComponent<attackAudio>();

        AudioObj = GameObject.Find("Audios");
        m_audioManager = AudioObj.GetComponent<AudioManager>();

        scoreManagerObj = GameObject.Find("Kill");
        m_scoreManager = scoreManagerObj.GetComponent<ScoreManager>();

        minPosX = Screen.width / 16f * 6.5f;
        maxPosX = Screen.width / 16f * 9f;
        minPosY = Screen.height / 16f * 6.5f;
        maxPosY = Screen.height / 16f * 9f;

        animationTest.state.Event += Event;
        animationTest.state.End += state_End;

        //animationTest.state.End += (state, trackIndex) =>
        //{
        //    Debug.Log("start: " + state.GetCurrent(trackIndex));
        //};
        //animationTest.state.End += ActionChange;
    }
Exemple #9
0
 void _Init()
 {
     _radius      = _DEFAULT_BOMB_RADIUS;
     _shakeScreen = GameObject.FindWithTag("GameView").GetComponent <ShakeScreen>();
     iTween.ShakeScale(gameObject, new Vector3(0.5f, 0, 0), 3);
 }
        public override void Enter()
        {
            this.resourceAssets.LoadResources(Constants.FONT_NAMES, Constants.TEXTURES_NAMES, Constants.SOUND_NAMES);
            cAnimationAssets.LoadAnimations(this.resourceAssets);

            BulletBreed.Init(this.resourceAssets);
            PickupEffects.InitPickupEffects(this.resourceAssets);

            camera      = new Camera(new View(new Vector2f(appControllerRef.WindowSize.X / 2.0f, appControllerRef.WindowSize.Y / 2.0f), appControllerRef.WindowSize));
            camera.Zoom = 0.6f; //  0.6f;

            appControllerRef.MainWindow.SetView(camera.View);

            /*
             * Vector2f viewSize = new Vector2f(appController.MainWindow.Size.X, appController.MainWindow.Size.Y);
             *
             * m_View.Size = new Vector2f(viewSize.X, viewSize.Y);
             * m_View.Center = new Vector2f(viewSize.X / 2.0f, viewSize.Y / 2.0f);
             * m_View.Viewport = new FloatRect(0.0f, 0.0f, 1.0f, 1.0f);
             * m_View.Zoom(0.6f); //0.6f
             *
             * viewRect = new AABB();
             * viewRect.SetDims(m_View.Size);
             */

            worldEnvironment = new cEnvironment();

            // Constants.LIGHTMAP_COLOR
            lightMap  = new cLightSystem(Constants.LIGHTMAP_COLOR, this.resourceAssets); //((uint)m_World.WorldBounds.dims.X, (uint)m_World.WorldBounds.dims.Y, Constants.LIGHTMAP_COLOR);
            gameWorld = new cWorld(this, appControllerRef.MainWindow.Size);

            gameWorld.InitLevel();

            //lightMap.Create((uint)m_World.WorldBounds.dims.X, (uint)m_World.WorldBounds.dims.Y);
            lightMap.Create(appControllerRef.MainWindow.Size.X, appControllerRef.MainWindow.Size.Y);

            lightMap.loadLightsFromTmxMap(gameWorld.CurrentLevel.GetTmxMap());

            this.staticTexture = new RenderTexture((uint)gameWorld.WorldBounds.dims.X, (uint)gameWorld.WorldBounds.dims.Y);
            this.staticTexture.SetActive(true);
            this.staticTexture.Clear(new Color(0, 0, 0, 0));
            //this.staticTexture.SetView(m_View);


            Vector2f playerStart = new Vector2f(gameWorld.LevelStartRegion.center.X, gameWorld.LevelStartRegion.rightBottom.Y);

            playerStart.X -= Constants.CHAR_FRAME_WIDTH / 2.0f;
            playerStart.Y -= Constants.CHAR_FRAME_HEIGHT;

            player = new cPlayer(this, playerStart);

            entityPool = new GameObjectGrid(this, gameWorld.WorldBounds.dims, player);
            entityPool.InitLevelEntites(World.CurrentLevel);

            //vizekhez adunk fényt

            /*
             * List<cWaterBlock> waterBlocks = m_World.GetWaterBlocks();
             *
             * foreach (cWaterBlock wb in waterBlocks)
             * {
             *  cLight waterLight = new cLight(); //víz blokkokhoz adunk fényt, mert jól néz ki
             *  waterLight.Pos = new Vector2f(wb.Area.center.X, wb.Area.topLeft.Y+Constants.TILE_SIZE/2.0f);
             *  waterLight.Radius = (wb.Area.dims.X + wb.Area.dims.Y) * 0.8f;
             *  waterLight.Bleed = 0.00001f; // 0.00001f;
             *  waterLight.LinearizeFactor = 0.95f;
             *  waterLight.Color = new Color(41,174,232); // 96,156,164
             *  lightMap.AddStaticLight(waterLight);
             * }
             *
             * //háttér, környezeti tárgyak megjelenítése
             * worldEnvironment.SetWaterBlocks(waterBlocks);
             */

            this.particleManager = new cParticleManager(this);
            this.effectSystem    = new EffectSystem();
            // lightMap.renderStaticLightsToTexture();

            gameActions = new Queue <Action>(50);

            Listener.GlobalVolume = 80;
            Listener.Direction    = new Vector3f(1.0f, 0.0f, 0.0f);

            ShakeScreen.Init(camera.ActualPosition);
            //Pálya idő start
            levelTimer.Start();
        }
Exemple #11
0
 // Start is called before the first frame update
 void Start()
 {
     health      = maxHealth;
     bulletCount = 0;
     Shake       = GameObject.FindGameObjectWithTag("ScreenShake").GetComponent <ShakeScreen>();
 }
 // Use this for initialization
 void Start()
 {
     SwordChild = GameObject.Find("Sword");
     shake      = GameObject.FindGameObjectWithTag("ScreenShake").GetComponent <ShakeScreen>();
 }