Example #1
0
    // logic //

    public override void _Ready()
    {
        if (Engine.EditorHint)
        {
            return;
        }
        base._Ready();

        dynamicCameraSingleton = (DynamicCameraSingleton)GetNode("/root/DynamicCameraSingleton");
        consoleSingleton       = GetNode <DebugConsole>("/root/DebugConsole");
        animatedSprite         = GetNode <AnimatedSprite>("CharacterSprite");
        attackArea             = GetNode <Area2D>("AttackArea");
        swordSlashAnimation    = GetNode <AnimatedSprite>("AttackArea/SwordSlashAnimation");
        globalState            = GetNode <GlobalState>("/root/GlobalState");


        animatedSprite.Play("idle");


        health = maxHealth;

        Node possibleInGameUi = GetNode(inGameUiPath);

        if (possibleInGameUi is InGameUi)
        {
            inGameUi = (InGameUi)possibleInGameUi;
        }

        meleeCooldownProgress = meleeCooldown;

        consoleSingleton.RegisterCommand("godmode", "Disable all player damage", OnGodmode);
    }
 // Use this for initialization
 void Start()
 {
     time       = timeBetwenSpawns;
     player     = GameObject.FindGameObjectWithTag("Player");
     inGameUi   = inGameCanvas.GetComponent <InGameUi>();
     gameOverUi = gameOverCanvas.GetComponent <GameOverUi>();
 }
Example #3
0
 public void Bind(Game game)
 {
     inputManager = game.InGameUi.InputManager;
     ui           = game.InGameUi;
     cam          = game.Camera;
     arrow        = game.InGameUi.TargetingArrow;
 }
Example #4
0
    //void DoPlayStart()
    //{
    //    GameController.Static.currentGameState = GameController.GameState.gameplay;
    //    MainMenuParent.SetActive(false);
    //    InGameUi.SetActive(true);
    //    CameraFade.current.FadeIn(null, 1f, 0f);
    //}

    public void OnButtonClick(string ButtonName)
    {
        switch (ButtonName)
        {
        case "Play":             // start intro animation, enable ingameUI
            CameraFade.current.FadeOut(CameraFade.current.FadeInTest, 0.3f, 0f);
            GameController.Static.OnGameStart();
            SoundController.Static.playSoundFromName("Click");
            MainMenuParent.SetActive(false);
            InGameUi.SetActive(true);
            TotalCoinsParent.SetActive(false);
            break;

        case "PlayerSelect":
            CameraFade.current.FadeOut(CameraFade.current.FadeInTest, 0.3f, 0f);
            Invoke("OpenPlayerSelection", 0.2f);
            break;

        case "Credits":
            SoundController.Static.playSoundFromName("Click");
            MainMenuParent.SetActive(false);
            CreditsMenuParent.SetActive(true);
            TotalCoinsParent.SetActive(false);
            currentScreen = MenuScreens.CredtsMenu;
            break;

        case "Exit":
            SoundController.Static.playSoundFromName("Click");
            ExitParent.SetActive(true);
            MainMenuParent.SetActive(false);
            TotalCoinsParent.SetActive(false);
            Application.Quit();
            break;

        case "Store":
            CameraFade.current.FadeOut(CameraFade.current.FadeInTest, 0.3f, 0f);
            Invoke("OpenUpgradesMenu", 0.2f);
            break;

        case "Missions":
            //CameraFade.current.FadeOut(CameraFade.current.FadeInTest, 0.3f, 0f);
            Invoke("OpenMissionsMenu", 0.2f);
            break;

        case "Settings":
            //CameraFade.current.FadeOut(CameraFade.current.FadeInTest, 0.3f, 0f);
            Invoke("OpenSettingsMenu", 0.2f);
            break;

        case "PauseMenu":
            //CameraFade.current.FadeOut(CameraFade.current.FadeInTest, 0.3f, 0f);
            SettingsMenuParent.SetActive(true);
            MainMenuParent.SetActive(false);
            TotalCoinsParent.SetActive(false);
            SoundController.Static.playSoundFromName("Click");
            currentScreen = MenuScreens.PauseMenu;
            break;
        }
    }
    public ScoreManager(InGameUi inGameUi)
    {
        _inGameUi = inGameUi;

        _bestScore        = PlayerPrefs.GetInt(BestScoreKey, 0);
        _currentBestScore = _bestScore;
        _score            = 0;
        UpdateDisplay();
    }
Example #6
0
    // on object creation
    void Awake()
    {
        GameObject[] objs = GameObject.FindGameObjectsWithTag("inGameManager");

        if (objs.Length > 1)
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this.gameObject);

        GameUI = gameObject.transform.GetComponentInChildren <InGameUi>();
    }
Example #7
0
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;

        if (PV.IsMine)
        {
            EquipItem(0);
            InGameUi = Instantiate(InGameUi, Vector3.zero, Quaternion.identity);
            InGameUi.transform.parent        = gameObject.transform;
            inGameUiController               = InGameUi.GetComponent <InGameUi>();
            inGameUiController.healthManager = GetComponent <HealthManager>();
            score = inGameUiController.GetComponentInChildren <ScoreCounter>();
        }
        else
        {
            Destroy(GetComponentInChildren <Camera>().gameObject);
        }
    }
Example #8
0
    IEnumerator FinalizeSetupRound(int gamemode, int viewId)
    {
        yield return(new WaitForSeconds(.5f));

        //Gamemode must be instantiated over network
        var obj = GameObject.Instantiate(_GameModeCollection.GetItem(gamemode));

        obj.name = "GameMode";
        var gameMode = obj.GetComponent <GameMode>();

        var pObj      = GameObject.FindGameObjectWithTag("Playfield");
        var playfield = pObj.GetComponent <Playfield>();

        gameMode.Initialize(playfield);

        var view = gameMode.photonView;

        view.viewID            = viewId;
        view.ownershipTransfer = OwnershipOption.Takeover;
        view.ObservedComponents.Add(gameMode);

        _gm       = gameMode;
        _inGameUi = Instantiate(Resources.Load <GameData>("GameData").InGameUi).GetComponent <InGameUi>();

        //Must be done on all clients
        var players = Container <IPlayerManager> .Instance.Items;

        foreach (var player in players)
        {
            if (PhotonNetwork.offlineMode)
            {
                player.CreatePlayer(playfield.GetSpawnLocation(player.Index));
            }
            else if (player.Index == (int)PhotonNetwork.player.CustomProperties["Index"])
            {
                player.CreatePlayer(playfield.GetSpawnLocation(player.Index));
            }
            else if (PhotonNetwork.isMasterClient && player.Ai)
            {
                player.CreatePlayer(playfield.GetSpawnLocation(player.Index));
            }
        }
    }
Example #9
0
    void Awake()
    {
        _camera = FindObjectOfType <Camera>();

        _deltaCameraCharacter = Camera.main.orthographicSize / 5;
        _lvlWidth             = Camera.main.orthographicSize * 2.0f * Camera.main.aspect;

        _gameLogic = FindObjectOfType <GameLogic>();

        _movingController = GetComponent <MovingController>();
        _movingController.SetForceCoef(_characterData.ForceJumpCoef);
        _movingController.SetFlyingSpeed(_characterData.FlyingSpeed);

        _attackController = GetComponent <AttackController>();

        _rigidbody = GetComponent <Rigidbody2D>();
        _ui        = FindObjectOfType <InGameUi>();
        _visual    = GetComponent <Visual>();


        _armorCoroutine   = ArmorLogic();
        _magnetCoroutine  = MagnetLogic();
        _jetpackCoroutine = JetpackLogic();
    }
Example #10
0
 private void Start()
 {
     _ui            = FindObjectOfType <InGameUi>();
     Time.timeScale = 1.0f;
 }
 private void Start()
 {
     _inGameUi = FindObjectOfType <InGameUi>();
 }