// Start is called before the first frame update
 void Start()
 {
     healthComp           = gameObject.GetComponent <EnemyHealth>();
     transform.localScale = new Vector3(healthComp.currentHealth * SIZEOVERHEALTH, healthComp.currentHealth * SIZEOVERHEALTH, healthComp.currentHealth * SIZEOVERHEALTH);
     maxHealth            = healthComp.currentHealth;
     GC = GameObject.Find("InGameController").GetComponent <InGameController>();
 }
Example #2
0
 private void Awake()
 {
     if (InGame == null)
     {
         InGame = this;
     }
 }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        _uniqueInstance = this;
        _curGameState   = eGameState.READY;

        //SoundManager._uniqueInstance.PlayBGMSound(SoundManager.eBGMType.INGAME);
    }
Example #4
0
    IEnumerator DelayBOTAttack(float wait)
    {
        yield return(new WaitForSeconds(wait));

        InGameController controller = GameObject.FindGameObjectWithTag(Tags.SCENE_CONTROLLER).GetComponent <InGameController>();

        controller.BOTAttack();
    }
Example #5
0
    void normalScore()
    {
        ScoreManager.killValue = 100;

        InGameController inGameController = GameObject.Find("InGameController").GetComponent <InGameController>();

        inGameController.multiplier = false;
    }
    // Start is called before the first frame update
    void Start()
    {
        // Find the InGame Controller
        GameObject controller = GameObject.Find("InGameController");

        GC      = controller.GetComponent <InGameController>();
        animate = true;
    }
Example #7
0
    public override void InitControllers()
    {
        InGameController = new InGameController();
        InGameController.Init(_inGameMenuConfig);

        MainMenuController = new MainMenuController(InGameController);
        MainMenuController.Init(_mainMenuConfig);


        MainMenuController.OpenWindow();
    }
Example #8
0
    void applyRandomPowerUp()
    {
        float   randomNum = Random.value;
        Vector3 position;

        if (randomNum <= 0.1)
        {
            // Damage all enemies power up
            GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
            foreach (GameObject enemy in enemies)
            {
                HealthManager healthManager = enemy.GetComponent <HealthManager>();
                healthManager.ApplyDamage(200);
            }
        }
        else if (randomNum <= 0.4 && randomNum > 0.1)
        {
            // Infinite Ammo Power Up
            PlayerReload playerReload = GetComponent <PlayerReload>();
            playerReload.maxAmmo = 300;
            playerReload.ReloadAction(300);
            fireRate = 1000000f;
            ParticleSystem infAmmoParticleSystem = this.transform.Find("InfAmmo").GetComponent <ParticleSystem>();
            infAmmoParticleSystem.enableEmission = true;
            Invoke("normalReload", 5);
        }
        else if (randomNum <= 0.7 && randomNum > 0.4)
        {
            // Health Buff Power Up
            PlayerHealth playerHealth = this.gameObject.GetComponent <PlayerHealth>();
            playerHealth.maxHealth = 10000;

            HealthManager healthManager = GetComponentInParent <HealthManager>();
            healthManager.currentHealth = 10000;
            playerHealth.OnEnable();
            playerHealth.ModifyHealth(0);
            GameObject forceField = this.transform.Find("ForceField").gameObject;
            forceField.SetActive(true);
            Invoke("normalHealth", 5);
        }
        else
        {
            // Score Multiplier Power Up
            ScoreManager.killValue *= 2;

            InGameController inGameController = GameObject.Find("InGameController").GetComponent <InGameController>();
            inGameController.multiplier = true;
            Invoke("normalScore", 20);
        }
    }
Example #9
0
    // Handle collisions
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Exit")
        {
            Cursor.lockState = CursorLockMode.None;
            InGameController.PlayerWon();
        }

        if (col.gameObject.tag == "River")
        {
            Cursor.lockState = CursorLockMode.None;
            InGameController.GameOver();
        }
    }
    // Start is called before the first frame update
    public void UpdatePanel()
    {
        InGameController igc = FindObjectOfType <InGameController>();
        CardController   cC  = FindObjectOfType <CardController>();

        igc.inGameAnim.SetBool("ShowCanvas", false);
        if (PlayerPrefs.GetInt("GameMode", 1) == 1)
        {
            timeText.text         = "Time Used: " + igc.currentTime.ToString() + " s.";
            recordTimeText.text   = "Record Time: " + PlayerPrefs.GetInt("RecordTime", 0).ToString() + " s.";
            attemptText.text      = "Attempt Used: " + cC.attempt.ToString();
            recordAttemtText.text = "Record Attempt: " + PlayerPrefs.GetInt("RecordAttempt", 0).ToString();
            modeName.SetActive(false);
        }
        else
        {
            modeName.SetActive(true);
            timeText.text         = "Time Used: " + igc.currentTime.ToString() + " s.";
            recordTimeText.text   = "Record Time: " + PlayerPrefs.GetInt("BlindRecordTime", 0).ToString() + " s.";
            attemptText.text      = "Attempt Used: " + cC.attempt.ToString();
            recordAttemtText.text = "Record Attempt: " + PlayerPrefs.GetInt("BlindRecordAttempt", 0).ToString();
        }


        if (igc.timeRecord)
        {
            timeRecordHeader.SetActive(true);
            recordTimeText.text = "Previous Record Time: " + PlayerPrefs.GetInt("PreviousRecordTime", 0).ToString() + " s.";
            igc.timeRecord      = false;
        }
        else
        {
            timeRecordHeader.SetActive(false);
        }

        if (cC.attemptRecord)
        {
            attemtRecordHeader.SetActive(true);
            recordAttemtText.text = "Previous Record Attempt: " + PlayerPrefs.GetInt("PreviousRecordAttempt", 0).ToString();
            cC.attemptRecord      = false;
        }
        else
        {
            attemtRecordHeader.SetActive(false);
        }
    }
Example #11
0
    // Start is called before the first frame update
    void Start()
    {
        GC = GameObject.Find("InGameController").GetComponent <InGameController>();
        mainForestMusic = mainForest.clip;
        bossMusic       = boss.clip;
        boss.enabled    = false;
        chickenSounds   = chicken.clip;
        windSounds      = wind.clip;
        throwSound      = throwAction.clip;
        explodeSound    = explosion.clip;
        pickUpSound     = pickUp.clip;
        powerUpSound    = powerUp.clip;
        healingSound    = heal.clip;

        windSoundDelay    = 10.0f;
        chickenSoundDelay = 15.0f;
        StartCoroutine(PlayWind());
        StartCoroutine(PlayChicken());
    }
    // Start is called before the first frame update
    public void StartGameMode()
    {
        /*
         * for each image index i will choose 2 random card index from available card:
         * so when player tap on cards the image acociated with it gets repleced with the existing card image
         */
        cardMemory = new int[cards.Length];
        iconStatus = new int [icons.Length]; // value defines number of times it is used
        cardsChild = new GameObject [cards.Length];
        //i have made 2 radomizing method, I dont wanna delete any of those so will use any of those randomly
        //update 2nd randomizing methods seems to randomize it better so only gonna use this now
        //AssignIcons();
        //Debug.Log("Assigning method");
        //Debug.Log("Random method method");
        igc = FindObjectOfType <InGameController>();
        if (PlayerPrefs.GetInt("GameMode", 1) == 1)
        {
            RandomizeIcons();
            ShowAllCards();
            HideCardChild();
            countDownTimeCount = countDownTime;
            igc.UpdateCountDown(countDownTime);
            igc.UpdateInGameUI();
            attempt = 0;
            FindObjectOfType <InGameController>().UpdateAttempt(attempt);

            igc.gameFinished = true;
            startCountDown   = true;
            timer            = 0;
            //FindObjectOfType<SFXManager>().Play("buttonClick");
        }
        else
        {
            RandomizeIcons();
            GamePlayStarts();
            igc.UpdateInGameUI();//works just like start
            igc.gameFinished = false;
        }
        igc.inGameAnim.SetBool("ShowCanvas", true);
    }
Example #13
0
    private void AfterChange(GameState oldState)
    {
        if (IsFieldUpdated(oldState, CurrentState, "CurrentState"))
        {
            switch (CurrentState.CurrentState)
            {
            case State.ARRANGE_SHIPS:
            {
                Logger.Log("GameManager: ARRANGE_SHIPS");
                if (Connection.Instance.OpId == null)
                {
                    Logger.Log("GameManager: retrieve OpId from CurrentState");
                    Connection.Instance.OpId = isHost ? CurrentState.GuestPlayerId : CurrentState.HostPlayerId;
                }
                SceneManager.LoadSceneAsync(Constants.SCENE_INDEX_PREGAME);
                break;
            }

            case State.BEGIN_BATTLE:
            {
                Logger.Log("GameManager: BEGIN_BATTLE");
                SceneManager.LoadSceneAsync(Constants.SCENE_INDEX_INGAME);
                break;
            }

            case State.PICK_CELL:
            {
                Logger.Log("GameManager: PICK_CELL");
                InGameController controller = GameObject.FindGameObjectWithTag(Tags.SCENE_CONTROLLER).GetComponent <InGameController>();
                controller.StartTurn(IsMyTurn());
                break;
            }

            case State.FIRE:
            {
                Logger.Log("GameManager: FIRE");
                InGameController controller = GameObject.FindGameObjectWithTag(Tags.SCENE_CONTROLLER).GetComponent <InGameController>();
                TargetModel      target     = JsonUtility.FromJson <TargetModel>(CurrentState.Target);
                controller.DisplayAttack(target);
                break;
            }

            case State.CHECK_WIN:
            {
                Logger.Log("GameManager: CHECK_WIN");
                InGameController controller = GameObject.FindGameObjectWithTag(Tags.SCENE_CONTROLLER).GetComponent <InGameController>();
                int MyHp = isHost ? CurrentState.HostPlayerHealth : CurrentState.GuestPlayerHealth;
                int OpHp = isHost ? CurrentState.GuestPlayerHealth : CurrentState.HostPlayerHealth;
                controller.UpdateHPAndCheckWin(MyHp, OpHp);
                break;
            }

            case State.CHANGE_TURN:
            {
                Logger.Log("GameManager: CHANGE_TURN");
                // Short delay before starting new turn
                StartCoroutine(DelayBeginTurn(1));
                break;
            }

            case State.END_GAME:
            {
                Logger.Log("GameManager: END_GAME");
                bool             isWin      = CurrentState.PlayerWin == Connection.Instance.MyId;
                InGameController controller = GameObject.FindGameObjectWithTag(Tags.SCENE_CONTROLLER).GetComponent <InGameController>();
                controller.HandleWinner(isWin);
                break;
            }

            default: break;
            }
        }
        if (
            IsFieldUpdated(oldState, CurrentState, "HostPlayerShips") ||
            IsFieldUpdated(oldState, CurrentState, "GuestPlayerShips")
            )
        {
            if (isHost)
            {
                if (!CurrentState.HostPlayerShips.Equals("") && !CurrentState.GuestPlayerShips.Equals(""))
                {
                    Logger.Log("GameManager: All player are ready");
                    BeginBattle();
                }
            }
        }
    }
Example #14
0
File: Enemy.cs Project: Comts/git1
 public void SetIngameController(InGameController controller)
 {
     mController = controller;
 }
Example #15
0
 public void Lose()
 {
     Cursor.lockState = CursorLockMode.None;
     InGameController.GameOver();
 }
Example #16
0
    void Start()
    {
        GameObject controller = GameObject.Find("InGameController");

        GC = controller.GetComponent <InGameController>();
    }
 private void Awake()
 {
     // Get the health of the enemy and InGame Controller at start
     enemyHealth = GetComponent <EnemyHealth>();
     GC          = GameObject.Find("InGameController").GetComponent <InGameController>();
 }
Example #18
0
 public MainMenuController(InGameController inGame)
 {
     _inGameController = inGame;
 }
Example #19
0
    private void Awake()
    {
        GameObject levelsHolder = GameObject.Find("LevelZones");
        int        currentLevel = PlayerPrefs.GetInt("GameLevel");

        LevelDataController.LevelData currentLevelData = LevelDataController.GetLevelData(currentLevel);
        for (int i = 0; i < levelsHolder.transform.childCount; i++)
        {
            levelsHolder.transform.GetChild(i).gameObject.SetActive(false);
        }
        levelsHolder.transform.GetChild(currentLevel).gameObject.SetActive(true);
        GameObject    currentLevelHolder   = levelsHolder.transform.GetChild(currentLevel).gameObject;
        PlayableLevel currentPlayableLevel = currentLevelHolder.GetComponent <PlayableLevel>();

        currentPlayableLevel.Initialize();
        LineRendererPool lineRendererPool = FindObjectOfType <LineRendererPool>();

        PlayerController playerController = FindObjectOfType <PlayerController>();

        playerController.SetPlayerPath(currentLevelHolder.transform.GetChild(1).GetComponent <BezierSpline>());
        playerController.Orient();
        Weapon currentWeapon = Instantiate(Resources.Load <GameObject>("Prefabs/Weapons/" + currentLevelData._primaryWeaponCategory.ToString()), playerController.GetWeaponPivot()).GetComponent <Weapon>();

        currentWeapon.SetLineRendererPool(lineRendererPool);
        WeaponProjectilesRetriever weaponProjectilesRetriever = FindObjectOfType <WeaponProjectilesRetriever>();

        weaponProjectilesRetriever.SetWeapon(currentWeapon);
        playerController.SetWeapon(currentWeapon);
        playerController.gameObject.SetActive(false);
        InGameController _inGameController = FindObjectOfType <InGameController>();

        FindObjectOfType <HPBarBehaviour>().SetPlayerController(playerController);
        _inGameController._player = playerController.gameObject;
        FindObjectOfType <ShootButtonBehaviour>().SetPlayer(playerController);
        currentPlayableLevel.SetPlayerController(playerController);
        //Añado la recarga al botón de recarga
        GameObject.Find("ReloadButton").GetComponent <Button>().onClick.AddListener(() => playerController.Reload());
        currentWeapon.SetVfxBloodPool(GameObject.Find("VFXBloodPool").GetComponent <VFXPool>());
        //Asigno valores a la camara
        BezierSpline cameraPath = currentLevelHolder.transform.GetChild(2).GetComponent <BezierSpline>();
        CinematicCameraController cinematicCameraController = FindObjectOfType <CinematicCameraController>();

        cinematicCameraController.SetPath(cameraPath);

        //Creo los enemigos
        EnemySpawner[] enemySpawners = currentLevelHolder.GetComponentsInChildren <EnemySpawner>();
        foreach (EnemySpawner e in enemySpawners)
        {
            EnemyController enemyController   = null;
            GameObject      instantiatedEnemy = null;
            switch (e.GetEnemyType())
            {
            case EnemyType.Zombie:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Zombie"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.WalkingNightmare:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_WalkingNightmare"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.CrawlingNightmare:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_CrawlingNightmare"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Troll:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Troll"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Explosive:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Explosive"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Spitter:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Spitter"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.Bat:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_Bat"), e.transform.position, Quaternion.identity);
                break;

            case EnemyType.SkeletonZombie:
                instantiatedEnemy = Instantiate(Resources.Load <GameObject>("Prefabs/Enemies/Enemy_SkeletonZombie"), e.transform.position, Quaternion.identity);
                break;
            }
            enemyController = instantiatedEnemy.GetComponent <EnemyController>();
            enemyController.SetPath(e.GetComponent <BezierSpline>());
            enemyController.SetMaxHp(e._maxHP);
            enemyController.SetCurrentHP(e._maxHP);
            enemyController.SetDamage(e._damage);
            enemyController.SetChaseIndex(e._chaseIndex);
            enemyController.SetChaseSpeed(e._speed * (1 + e.animationSpeedOffset));
            enemyController.SetChaseAnimationSpeedOffset(1 + e.animationSpeedOffset);
            enemyController.SetSkin(e._skin);
            enemyController.Orient();
            enemyController.SetPlayerController(playerController);
            if (!e._preInstantiate)
            {
                instantiatedEnemy.SetActive(false);
            }
            currentPlayableLevel._enemyControllers.Add(enemyController);
        }
    }
Example #20
0
 public InGameState()
 {
     Controller = new InGameController(this);
 }