Exemplo n.º 1
0
        private void SpawnRandomSyringe()
        {
            int            num         = GameState.Random.Next(5);
            PowerupFactory pickFactory = new PowerupFactory();
            Pickupable     syringe;

            switch (num)
            {
            case 0:
                syringe = pickFactory.GetPowerup("MovementSyringe");
                break;

            case 1:
                syringe = pickFactory.GetPowerup("ReloadSyringe");
                break;

            case 2:
                syringe = pickFactory.GetPowerup("HealingSyringe");
                break;

            default:
                syringe = pickFactory.GetPowerup("DeflectionSyringe");
                break;
            }

            bool isSpawned = ForceSpawnObject(syringe);

            if (isSpawned)
            {
                GameState.PickupableRep.GetIterator().Add(syringe);
                //GameState.Pickupables.Add(syringe);
            }
        }
    // Use this for initialization
    new void Start()
    {
        /** START Merge from Root **/
        isBackAtSpawner = true;
        PowerupFactory puf = PowerupFactory.GetPUF();

        transform.position = puf.transform.position;

        if (startReleased)
        {
            ProcessReleased();
        }
        /** END **/

        timeCreated = Time.time;
        // created with everything off
        DisablePhysicsAndRendering();
        affectedArea.DeActivate();

        Target tempMeAsTarget = this.GetComponent <Target>();

        if (tempMeAsTarget != null)
        {
            meAsTarget = tempMeAsTarget;
        }
    }
Exemplo n.º 3
0
        private void SetupAvaiblePowerups()
        {
            for (int i = 0; i < Grid.childCount; i++)
            {
                Grid.GetChild(i).gameObject.SetActive(false);
            }

            PowerupSlot first = null;

            foreach (IPowerup powerup in PowerupFactory.GetAllPowerups())
            {
                var obj = ObjectPool.Instantiate(PowerupIcon, Vector3.zero);
                obj.transform.localScale = new Vector3(1, 1, 1);

                obj.transform.SetParent(Grid);

                obj.GetComponent <PowerupSlot>().Setup(powerup);

                if (first == null || SelectedPowerup != null && powerup.GetType() == SelectedPowerup.GetType())
                {
                    first = obj.GetComponent <PowerupSlot>();
                }
            }

            SelectPowerup(first);
        }
Exemplo n.º 4
0
 private void Construct(SignalBus signalBus, EnemySpawner enemySpawner, FogManager fogManager, PowerupFactory powerupFactory, GameplaySettings gameplaySettings)
 {
     SignalBus         = signalBus;
     _enemySpawner     = enemySpawner;
     _fogManager       = fogManager;
     _powerupFactory   = powerupFactory;
     _gameplaySettings = gameplaySettings;
 }
    void OnUsePowerUp(bool check)
    {
        //ToyBox.GetPandora().CommandCenter_01.pow

        bool isActive = PowerupFactory.GetPUF().ToggleFactory();

        Debug.Log("Spawner is " + isActive);
    }
        private void SetupSprite(Colour pieceColour)
        {
            this.colour  = pieceColour;
            Image.sprite = GameResources.PieceSprites[((int)pieceColour).ToString()];

            Powerup = PowerupFactory.GetPowerup(pieceColour);
            PowerupSlot.Setup(Powerup, false);
        }
Exemplo n.º 7
0
    public void Spawn(Transform trans = null, PowerupFactory.PowerUpsDirectoryType newSpawnType = PowerupFactory.PowerUpsDirectoryType.RANDOM)
    {
        if (_active && maxSpawnCount < 0 || currSpawnCount <= maxSpawnCount)
        {
            if (PowerupFactory.GetPUF() == null)
            {
                return;
            }

            int randType = 0;


            if (newSpawnType == PowerupFactory.PowerUpsDirectoryType.RANDOM)             //spawnRandom){
            {
                randType = Random.Range(0, PowerupFactory.GetPUF().powerUpRootTypes.Count);
            }
            else
            {
                randType = (int)newSpawnType;                //(int)spawnType;
            }
//



            PowerupBase spawnPU = PowerupFactory.GetPUF().GetPowerUp((PowerupFactory.PowerUpsDirectoryType)randType);
            if (spawnPU)
            {
                // make sure its active
                spawnPU.gameObject.SetActive(true);

                // who ever triggers spawn can set it to a transform
                if (trans != null)
                {
                    spawnPU.transform.position = trans.position;
                }
                else
                {
                    spawnPU.transform.position = this.transform.position;
                }
                spawnPU.ProcessReleased();
                if (spawnPU.GetComponent <Rigidbody>())
                {
                    float randX = Random.Range(0, spawnForceX);
                    float randY = Random.Range(0, spawnForceY);
                    float randZ = Random.Range(0, spawnForceZ);
                    spawnPU.GetComponent <Rigidbody>().AddForce(randX, randY, randZ);
                }
                releasedPowerUpTime = Time.time;
                currSpawnCount++;
            }
            else
            {
                releasedPowerUpTime = 0;
            }
        }
    }
Exemplo n.º 8
0
        private void SpawnMedkit()
        {
            PowerupFactory pickFactory = new PowerupFactory();
            Pickupable     medkit      = pickFactory.GetPowerup("Medkit");
            bool           isSpawned   = ForceSpawnObject(medkit);

            if (isSpawned)
            {
                GameState.PickupableRep.GetIterator().Add(medkit);
                //GameState.Pickupables.Add(medkit);
            }
        }
    public void ProcessBackToSpawner()
    {
        /** Merge with Root **/
        // print ("ProcessBackToSpawner");

        DisablePhysicsAndRendering();
        transform.position = PowerupFactory.GetPUF().transform.position;
        // we are no longer active, setting this flag will tell the factory to put it back to the active list
        isBackAtSpawner = true;

        /** END **/

        //DisablePhysicsAndRendering();
    }
Exemplo n.º 10
0
        private void CheckForCompletion(Colour PieceColour, int previous, int collected)
        {
            int increment = RemoteConfigHelper.GetCollectionInterval(PieceColour);

            var multiplier = (previous / increment) + 1;

            int powerupsEarned = NumberOfPowerupsEarned(previous, previous + collected, increment);

            for (int i = 0; i < powerupsEarned; i++)
            {
                PieceCollectionComplete?.Invoke(PieceColour);
                AddNewPowerup(PowerupFactory.GetPowerup(PieceColour));
            }
        }
Exemplo n.º 11
0
        public void Setup(IPowerup powerup)
        {
            Colour colour = Colour.None;

            foreach (Colour c in Enum.GetValues(typeof(Colour)))
            {
                if (powerup.GetType() == PowerupFactory.GetPowerup(c).GetType())
                {
                    colour = c;
                    break;
                }
            }

            GetComponentInChildren <Image>().sprite = GameResources.PieceSprites[((int)colour).ToString()];
        }
Exemplo n.º 12
0
 //True = boss dead
 public bool Hit(int damage)
 {
     health -= damage;
     if (NextPosition.y < GameLogic.ScreenHeight * 0.4f)
     {
         NextPosition.y += 3f;
         PrevPosition    = TheBoss.transform.position;
         MoveTime        = 0f;
     }
     if (health < 0)
     {
         PowerupFactory.ProduceExplosion(TheBoss.transform.position);
         Destroy();
         return(true);
     }
     return(false);
 }
    // Update is called once per frame
    void Update()
    {
        CheckTiming();
        if (!host && affectedArea)
        {
            // set the parent and the affect position to my rigid body, keep us together
            // position back to the factory!
            PowerupFactory puf = PowerupFactory.GetPUF();
            affectedArea.transform.localPosition.Set(puf.transform.position.x, puf.transform.position.y, puf.transform.position.z);
            affectedArea.transform.position = GetComponent <Rigidbody>().position;
        }

        if (host && affectedArea)
        {
//			if (host.rigidbody){
            //affectedArea.transform.position = host.rigidbody.position;
            //rigidbody.position = host.rigidbody.position;
            //}
            // if we have a host that means our physics body is deactive and kinetic.  we can update the position
            // updating the position of the affected area, most affective areas will
            // be locked on the positon of the bot
            if (host.transform && keepAffectedAreaOnHost)
            {
                affectedArea.transform.localPosition.Set(0.0f, 0.0f, 0.0f);
                affectedArea.transform.position = host.transform.position;

                GetComponent <Rigidbody>().position = host.transform.position;
                //rigidbody.MovePosition(host.transform.position);
            }
        }
        if (!isPickedup)
        {
            affectedArea.DeActivate();
        }
        if (meAsTarget != null)
        {
            //Debug.Log("PowerupBase Has a target!!!!!!!");
            if (this.IsDestroyed())
            {
                Debug.Log("PowerupBase Is Destroyed!!!!!");

                this.DisablePhysicsAndRendering();
                ProcessBackToSpawner();
            }
        }
    }
Exemplo n.º 14
0
 private void Reset()
 {
     for (int bullet = 0; bullet < mPlayerCharacter.Weapon.ActiveBullets.Count; bullet++)
     {
         mPlayerCharacter.Weapon.ActiveBullets[bullet].SetActive(false);
     }
     if (boss != null)
     {
         boss.Destroy();
         boss = null;
     }
     mPlayerCharacter.Reset();
     mCurrentDifficulty.Reset();
     EnemyFactory.Reset();
     PowerupFactory.Reset();
     mMissedEnemies     = 0;
     mDistanceTravelled = 0.0f;
     mLevelTimeLeft     = DifficultyCurve.LevelDuration;
     GameText.text      = "";
 }
Exemplo n.º 15
0
    void OnClick()
    {
        //if (spawner){
        //PowerupFactory.GetPUF().allowSpawn = !PowerupFactory.GetPUF().allowSpawn;
        bool isActive = PowerupFactory.GetPUF().ToggleFactory();

        //spawner.Toggle();
        if (myLabel)
        {
            if (isActive)
            {
                myLabel.text = "Spawner On";
            }
            else
            {
                myLabel.text = "Spawner Off";
            }
        }
        //}
    }
Exemplo n.º 16
0
        public async Task ReadEquippedPowerupsAsync()
        {
            try
            {
                await FireBaseDatabase.Database.Child(FireBaseSavePaths.PlayerEquippedPowerupLocation())
                .GetValueAsync().ContinueWith(task =>
                {
                    if (task.IsFaulted)
                    {
                    }
                    else if (task.IsCompleted)
                    {
                        try
                        {
                            DataSnapshot snapshot = task.Result;

                            string info = snapshot?.GetRawJsonValue()?.ToString();

                            var result = new string[0];
                            if (info != null)
                            {
                                result = JsonHelper.FromJson <string>(info);
                            }

                            for (int i = 0; i < result.Length; i++)
                            {
                                UserPowerupManager.Instance.EquippedPowerups[i] = PowerupFactory.GetPowerup(result[i]);
                            }
                        }
                        catch (Exception ex)
                        {
                            Debug.LogError(ex);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                DebugLogger.Instance.WriteException(ex);
            }
        }
Exemplo n.º 17
0
    void Update()
    {
        //Nicely move the caracter
        Vector3 position = transform.position;

        if (mTargetPosition != position.x)
        {
            mMovementTime     += GameLogic.GameDeltaTime * GameLogic.PlayerSpeed;
            position.x         = Mathf.SmoothStep(mStartPosition, mTargetPosition, mMovementTime);
            transform.position = position;
        }

        //Search for powerups
        int CollectedPowerup = PowerupFactory.DetectCollisions(transform.position);

        if (CollectedPowerup >= 0)
        {
            Inventory[CollectedPowerup]++;
            TriggerTutorial(16);
        }
    }
Exemplo n.º 18
0
    void Start()
    {
        PowerupFactory puf = PowerupFactory.GetPUF();

        if (puf == null)
        {
            return;
        }
        bool isActive = puf.IsSpawning();

        if (myLabel)
        {
            if (isActive)
            {
                myLabel.text = "Spawner On";
            }
            else
            {
                myLabel.text = "Spawner Off";
            }
        }
    }
Exemplo n.º 19
0
        public async Task ReadPowerupsAsync()
        {
            try
            {
                await Task.Run(() =>
                {
                    var result = FireBaseReader.ReadAsync <PowerupEntity>(FireBaseSavePaths.PlayerPowerupLocation());

                    foreach (var entity in result.Result)
                    {
                        UserPowerupManager.Instance.Powerups.Add(new PowerupCollection()
                        {
                            Powerup = PowerupFactory.GetPowerup(entity.Name), Count = entity.Count
                        });
                    }
                });
            }
            catch (Exception ex)
            {
                DebugLogger.Instance.WriteException(ex);
            }
        }
    /*
     * we want a list of lists.  Each item in the list Indexed by the Powerup Directory
     * Each item contains a list of the available pool of powerups of that type
     * Allocate the amount of each type index
     * We can then retrieve a powerup by the index and returning the first object available
     * if none is available it will create one and return the new one.
     *
     */



    //public PowerUpsDirectory puDirectory;

    // Use this for initialization
    void Start()
    {
        // set the instance
        PUF = this;

        poolUnavailablePowerUps = new List <PowerupBase>();

        // poolHashTableAvailablePowerups = new Dictionary<int, PowerupRoot>();

        objectListMemTypes = new List <PowerupMemoryList>();

        Transform myTransform = transform;

        /*
         * Testing with custom 2d Table
         * For each type of powerup, we create a list that contains a list of powerup objects
         *
         */
        for (int i = 0; i < powerUpRootTypes.Capacity; i++)
        {
            // the memory list
            PowerupMemoryList curr = new PowerupMemoryList();             // Instantiate(powerupMemoryListPrefabRef, Vector3.zero, Quaternion.identity) as PowerupMemoryList;   // when creating

            // set the type of list is to carry
            curr.SetType((PowerUpsDirectoryType)i);

            // this creates all the default starting allocation and its prefab of that type index
            curr.CreateMemObjects(startPoolWithTypeCount[i], powerUpRootTypes[i], myTransform);

            //Parent?


            // add the new list to the list of lists.
            objectListMemTypes.Add(curr);
        }
    }
Exemplo n.º 21
0
 public void Add(PowerupExe powerup)
 {
     powerups.Add(PowerupFactory.GetPowerup(powerup));
 }
Exemplo n.º 22
0
        public Pickupable GetPickupable()
        {
            PowerupFactory pickFactory = new PowerupFactory();

            return(pickFactory.GetPowerup("Medkit"));
        }
Exemplo n.º 23
0
    // Use this for initialization
    void Awake()
    {
        //print("EF START!!!");

        EF = this;

        //Dont destroy me.
        DontDestroyOnLoad(this.gameObject);

        //Create the target pool.
        TargetPool = new List <PooledObject <Target> >();

        //Create the list for active targets
        ActiveTargetList = new List <Target>();

        //Create list for active cannons
        ActiveCannonList = new List <Cannon>();

        //Create the cannon pool.
        CannonPool = new List <PooledObject <Cannon> >();

        //Create a pool for each item in each list we want to pool.
        int TargetTypeIndex = 0;

        //Creating the pools for each targets.
        foreach (Target t in TargetCatalogue)
        {
            PooledObject <Target> pT = new PooledObject <Target>();

            //Add 3 of each to start off with.
            for (int i = 0; i < PreAllocatedTargetCount; i++)
            {
                Target temp = Instantiate(t, Vector3.zero, Quaternion.identity) as Target;

                //Set the target ID
                temp.ID = (TargetTypes)TargetTypeIndex;

                temp.transform.parent = transform;

                //Add to the pool.
                pT.AddItem(temp);

                temp.ForceDisable();
            }

            //Add the pooled object to the target pool.
            TargetPool.Add(pT);

            TargetTypeIndex++;
        }


        foreach (Cannon c in CannonCatalogue)
        {
            //Create a pool per cannon type.
            PooledObject <Cannon> pC = new PooledObject <Cannon>();

            //Add the pooled object to the cannon pool ist.
            CannonPool.Add(pC);
        }

        PUF = Instantiate(PUF) as PowerupFactory;
        PUF.transform.parent = transform;
    }
Exemplo n.º 24
0
    void Update()
    {
        GameDeltaTime = Paused ? 0.0f : Time.deltaTime;

        if (mGameStatus == State.Level)
        {
            mDistanceTravelled += ScenerySpeed * GameDeltaTime;
            if (mDistanceTravelled != 0f)
            {
                UpdateText(string.Format("Distance: {0:0.0} m", mDistanceTravelled));
            }

            mLevelTimeLeft -= GameDeltaTime;

            if (!GameFrozen)
            {
                if (mLevelTimeLeft > 0f)
                {
                    //Get a bit pattern and spawn enemies according to it
                    int enemies = mCurrentDifficulty.SpawnPattern();
                    for (int ColumnCount = 0; ColumnCount < 3; ColumnCount++)
                    {
                        if ((enemies & (1 << ColumnCount)) != 0)
                        {
                            EnemyFactory.Dispatch((EnemyFactory.Column)ColumnCount);
                        }
                    }

                    PowerupFactory.DetectCollisions(mPlayerCharacter.transform.position);
                }
                else if (mActiveEnemies.Count == 0)
                {
                    switch (SlowDownStage)
                    {
                    case 0:     //We are just now starting to slow down
                        mCurrentDifficulty.SlowDown();
                        break;

                    //For case 1 - slowing down in progress - nothing is to be done
                    case 2:     //Slowing down has finished; switch to boss state
                        mGameStatus = State.Boss;
                        boss        = new Boss(GameplayCamera, EnemyMaterial);
                        mCurrentDifficulty.TriggerTutorial(11);
                        break;
                    }

                    //At this point, we know there are no enemies to check, so it is OK to skip the loop below
                    return;
                }
            }

            /* Traverse the list descendingly so that removals of already visited elements does not affect the
             * elements yet to be visited.
             */
            for (int count = mActiveEnemies.Count - 1; count >= 0; count--)
            {
                Vector3 ThisPosition = mActiveEnemies[count].transform.position;

                //Update each enemy's position according to the game speed
                ThisPosition.y -= GameDeltaTime * EnemySpeed;
                mActiveEnemies[count].transform.position = ThisPosition;

                //Check if the enemy has flown off screen. If so, return it to the factory and count it as missed.
                if (ThisPosition.y < ScreenHeight * -0.5f)
                {
                    EnemyFactory.Return(mActiveEnemies[count]);
                    mMissedEnemies++;
                }

                //Check if the enemy is too close to the player. If so, end the game.
                else if ((mPlayerCharacter.transform.position - ThisPosition).sqrMagnitude < PlayerKillDistance)
                {
                    GameOver("You died!");
                }

                //Check if the enemy has been hit by a bullet
                else
                {
                    for (int bullet = 0; bullet < mPlayerCharacter.Weapon.ActiveBullets.Count; bullet++)
                    {
                        if (mPlayerCharacter.Weapon.ActiveBullets[bullet].CheckHit(ThisPosition, BulletKillDistance, false))
                        {
                            EnemyFactory.Return(mActiveEnemies[count]);
                            break;
                        }
                    }
                }
            }

            //Check if the player has been "invaded" (too many enemies were missed
            if (mMissedEnemies >= MaxMissedEnemies)
            {
                GameOver("You have been invaded!");
            }
        }

        else if (mGameStatus == State.Boss)
        {
            if (boss != null)
            {
                //Only if the boss is allowed to move
                if (!GameFrozen)
                {
                    //Move and rotate boss to point to player's position
                    boss.Update(mPlayerCharacter.transform.position);

                    //Check if boss has eaten the player and if so end the game
                    if (boss.HasEaten(mPlayerCharacter.transform.position))
                    {
                        GameOver("You have been eaten!");
                    }
                }

                //Check wether boss was hit by a bullet
                foreach (Bullet bullet in mPlayerCharacter.Weapon.ActiveBullets)
                {
                    if (bullet.CheckHit(boss.Position(), BossHitDistance, true))
                    {
                        if (boss.Hit(bullet.DamageValue))
                        {
                            boss = null;
                            mCurrentDifficulty.TriggerTutorial(13);
                        }
                        break;
                    }
                }
            }

            //No more boss, transitioning to normal
            else
            {
                mDistanceTravelled += ScenerySpeed * GameDeltaTime;
                UpdateText(string.Format("Distance: {0:0.0} m", mDistanceTravelled));

                if (mCurrentDifficulty.LevelUp())
                {
                    mGameStatus    = State.Level;
                    mMissedEnemies = 0;
                    mLevelTimeLeft = DifficultyCurve.LevelDuration;
                }
            }
        }

        else if (mGameStatus == State.TapToStart)
        {
            mCurrentDifficulty.TriggerTutorial(1);
            if (mCurrentDifficulty.TutorialStage != 0)
            {
                mGameStatus = State.Level;
            }
            else
            {
                GameText.text = "Tap the screen or press W to start";
            }
        }
    }
        public Pickupable GetPickupable()
        {
            PowerupFactory pickFactory = new PowerupFactory();

            return(pickFactory.GetPowerup("HealingSyringe"));
        }