/// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Loading backgrounds
            background         = this.Content.Load <Texture2D>(@"backgrounds/back_city");
            startBackground    = this.Content.Load <Texture2D>(@"backgrounds/back_start");
            gameOverBackground = this.Content.Load <Texture2D>(@"backgrounds/back_gameover");
            pausedBackground   = this.Content.Load <Texture2D>(@"backgrounds/back_paused");

            //Loading interface elements
            cursorTexture = this.Content.Load <Texture2D>(@"Interface/Cursors/cursor");
            hud           = new PlayerHud(Services);
            play          = new Button(this.Content.Load <Texture2D>(@"Interface/Buttons/btn_play"),
                                       this.Content.Load <Texture2D>(@"Interface/Buttons/btn_playhvr"), new Vector2(362, 250));
            instructions = new Button(this.Content.Load <Texture2D>(@"Interface/Buttons/btn_instructions"),
                                      this.Content.Load <Texture2D>(@"Interface/Buttons/btn_instructionshvr"), new Vector2(362, 350));;
            playAgain = new Button(this.Content.Load <Texture2D>(@"Interface/Buttons/btn_playagain"),
                                   this.Content.Load <Texture2D>(@"Interface/Buttons/btn_playagainhvr"), new Vector2(362, 250));;
            continuePlaying = new Button(this.Content.Load <Texture2D>(@"Interface/Buttons/btn_continueplaying"),
                                         this.Content.Load <Texture2D>(@"Interface/Buttons/btn_continueplayinghvr"), new Vector2(362, 250));;
            quit = new Button(this.Content.Load <Texture2D>(@"Interface/Buttons/btn_quit"),
                              this.Content.Load <Texture2D>(@"Interface/Buttons/btn_quithvr"), new Vector2(362, 450));;

            //Setting initial game state and level index
            gameState  = GameState.Start;
            levelIndex = 1;
        }
 void OnTriggerExit(Collider other)
 {
     if (other.tag == "Player" && !permenantlyDisabled)
     {
         PlayerHud.ToggleInteractPrompt(false);
     }
 }
示例#3
0
    // Use this for initialization
    void Start()
    {
        default_resistance   = resistance;
        default_maxSpeed     = maxSpeed;
        default_jumpForce    = jumpForce;
        default_gravityScale = this.GetComponent <Rigidbody2D> ().gravityScale;
        onLadder             = false;
        isDead = false;

        contToUse = 1;

        anim  = GetComponent <Animator> ();
        rBody = GetComponent <Rigidbody2D> ();
        if (GameObject.Find("PlayerUI"))
        {
            ui = GameObject.Find("PlayerUI").GetComponent <PlayerHud>();
        }

        currentHealth = startingHealth;
        if (ui)
        {
            ui.updateHealth();
        }

        if (defaultWeapon == null)
        {
            Debug.LogError("No Default Weapon Set in PlayerController");
        }

        if (currentWeapon == null)
        {
            currentWeapon = Instantiate(defaultWeapon);
        }
        setWeapon();
    }
    public void CreatePlayerHuds(List <Player> players)
    {
        int playerNum = 0;

        foreach (Player player in players)
        {
            GameObject newPlayerHudObj = Instantiate(PlayerHudPrefab);

            RectTransform newPlayerRect = newPlayerHudObj.GetComponent <RectTransform>();
            newPlayerHudObj.transform.SetParent(HudCanvas.transform);
            newPlayerRect.pivot            = _pivotAnchorPosition;
            newPlayerRect.anchorMin        = _pivotAnchorPosition;
            newPlayerRect.anchorMax        = _pivotAnchorPosition;
            newPlayerRect.anchoredPosition = _hudPosition;

            PlayerHud newPlayerHud = newPlayerHudObj.GetComponent <PlayerHud>();
            newPlayerHud.AssignPlayerToHud(player);
            _playerHuds.Add(newPlayerHud);
            newPlayerHud.playerHud = newPlayerHudObj;
            ++playerNum;

            // Hide the new HUDs
            newPlayerHudObj.SetActive(false);
        }
    }
示例#5
0
    void Start()
    {
        _controllerName = name;

        _rigidbody = GetComponent <Rigidbody>();
        _fuel      = 100;

        _factions = new List <string> {
            "Faction1", "Faction2", "Faction3"
        };
        _players = new List <GameObject>();
        _factions.ForEach(x => _players.AddRange(GameObject.FindGameObjectsWithTag(x)));

        _playerHud = gameObject.GetComponent <PlayerHud>();

        _cannon = gameObject.GetComponentInChildren <Cannon>();

        _lockedRotationUntil = Time.time;

        _ammo = new Dictionary <AmmoType, int> {
            { AmmoType.Cannon, 50 }, { AmmoType.Missile, 10 }
        };

        GetComponent <Renderer>().material.color = Faction.Colour(tag);
    }
示例#6
0
    public void OnAssignedVehicle(Vehicle vehicle)
    {
        Debug.Log("Received a new vehicle:" + vehicle.name);
        if (hud == null)
        {
            var hudObject = Instantiate(hudPrefab) as GameObject;
            hud = hudObject.GetComponentInChildren <PlayerHud>();
            hud.quitMinigameButton.gameObject.SetActiveRecursively1(false);

            minimap   = hud.GetComponentInChildren <Minimap>();
            subtitles = hud.GetComponentInChildren <Subtitles>();
            var playerCamera = SetupGameplayCamera(vehicle.gameObject, vehicle.transform);
            minimap.cameraToFollow = playerCamera.GetComponent <Camera>();

            var avatarQuest = vehicle.GetComponentInChildren <AvatarQuest>();

            if (avatarQuest != null)
            {
                var minimapCamera = hud.GetComponentInChildren <MinimapCamera>();
                minimapCamera.objectToFollow = avatarQuest;

                var minimapSurface = hud.GetComponentInChildren <MinimapSurface>();
                minimapSurface.avatarToFollow = avatarQuest;
            }
        }
    }
示例#7
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(this.gameObject); return;
     }
     Instance = this;
 }
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && !permenantlyDisabled)
     {
         PlayerHud.SetInteractText(GetComponent <DisplayText>().displayText);
         PlayerHud.ToggleInteractPrompt(true);
     }
 }
示例#9
0
 // Only used for the bed/sleep trigger
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "Player" && name.Equals("Bed"))
     {
         PlayerHud.SetInteractText(GetComponent <DisplayText>().displayText);
         PlayerHud.ToggleInteractPrompt(TimeManager.IsInSleepTimeFrame());
         canInteract = TimeManager.IsInSleepTimeFrame();
     }
 }
示例#10
0
    private void InitializeHud()
    {
        InGameSceneMain inGameSceneMain = SystemManager.Instance.GetCurrentSceneMain <InGameSceneMain>();
        GameObject      go         = Resources.Load <GameObject>(playerHudPath);
        GameObject      goInstance = Instantiate(go, inGameSceneMain.DamageManager.CanvasTransform);
        PlayerHud       playerHud  = goInstance.GetComponent <PlayerHud>();

        playerHud.Initialize(this);
    }
示例#11
0
    public void SleepToMorning()
    {
        sleepPrompt.CloseMenu();
        PlayerHud.ToggleInteractPrompt(false);
        PlayerEnergy.RestoreEnergyPercentage(DetermineSleepDuration());
        TimeManager.ProgressToMorningTime();

        SaveLoad.Save();
    }
	public void OnTriggerExit(Collider other)
	{
		if (other.tag == "Player")
		{
			canInteract = false;

			PlayerHud.ToggleInteractPrompt(false);
		}
	}
示例#13
0
    void GradeSplitFirewoodBeforeUnsnap()
    {
        SetCanPerformAction(false);

        PlayerHud.ToggleQualityGame(true);
        QualityMinigame.StartGame();

        StartCoroutine(WaitForFirewoodGrade());
    }
示例#14
0
 public void Setup()
 {
     am     = MonoBehaviour.Instantiate(TestConstants.GetResource("Managers/Audio Manager")).GetComponent <AudioManager>();
     achm   = MonoBehaviour.Instantiate(TestConstants.GetResource("Managers/Achievement Manager")).GetComponent <AchievementManager>();
     gs     = MonoBehaviour.Instantiate(TestConstants.GetResource("Managers/Game Settings")).GetComponent <GameSettingsManager>();
     sm     = MonoBehaviour.Instantiate(TestConstants.GetResource("Managers/Shop Manager")).GetComponent <ShopManager>();
     player = MonoBehaviour.Instantiate(TestConstants.GetResource("Player"));
     ph     = player.GetComponent <PlayerHud>();
     sm.SetSelectedShipData(Resources.Load <ShipData>("Tests/Mock Ship"));
 }
	void OnTriggerEnter(Collider other)
	{
		if (other.tag == "Player")
		{
			canInteract = true;
			
			PlayerHud.SetInteractText(GetComponent<DisplayText>().displayText);
			PlayerHud.ToggleInteractPrompt(true);
			
		}
	}
示例#16
0
    void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
            canInteract = false;
            isMenuOpen  = false;

            PlayerHud.ToggleInteractPrompt(false);
            CloseMenu();
        }
    }
示例#17
0
    void Start()
    {
        PlayerHudReference = this;

        playerCanvas   = GetComponent <Canvas>();
        maxEnergyValue = PlayerSkills.GetMaxEnergyValue();

        toolIconGroup.parent.transform.parent.gameObject.SetActive(true);
        ChangeToolIcon();

        interactText = interactPrompt.transform.GetChild(3).GetComponent <Text>();
    }
示例#18
0
    public static void UnsnapPlayer()
    {
        PlayerHud.ToggleQualityGame(false);

        CharacterMotor.SetCanMove(true);
        CharacterInputController.SetCanTurn(true);
        CharacterInputController.InitiateLoggingState(AnimState.NONE);
        CharacterInputController.ToggleToolsInput(true);
        CharacterAnimator.ResetLoggingTriggers();

        Instance.GetComponent <Rigidbody>().constraints = startingConstraints;

        playerIsLocked = false;
    }
示例#19
0
        private void UpdateHudActivity()
        {
            //We are not worried about
            var currentOxygenPercentage = explorationDurationLeft / MaxExplorationTime;

            var updateValues = new HudUpdateData()
            {
                ExplorationLimitFill = currentOxygenPercentage,
                MineralText          = CurrentCurrencyBalance,
                IsFillingUp          = CurrentExplorationState == ExplorationState.Replenish,
                IsLow = currentOxygenPercentage < PercentageForLowEnergyNotification / 100.0f
            };

            PlayerHud.UpdateHud(updateValues);
        }
示例#20
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            if (name.Equals("Bed") && !TimeManager.IsInSleepTimeFrame())
            {
                return;
            }

            canInteract = true;

            PlayerHud.SetInteractText(GetComponent <DisplayText>().displayText);
            PlayerHud.ToggleInteractPrompt(true);
        }
    }
示例#21
0
    //End of update Method

    private void createPlayer()
    {
        playerContainer = Instantiate(playerPrefab).transform;
        player          = playerContainer.Find("PlayerEnt").GetComponent <PlayerController>();
        playerUI        = playerContainer.Find("PlayerUI").GetComponent <PlayerHud>();
        camera.setFollowing(player.gameObject);

        if (Input.GetJoystickNames().Length > 1)
        {
            player.setController(1);
        }
        else
        {
            player.setController(1);
        }
    }
示例#22
0
    private void createPlayer()
    {
        playerContainer = Instantiate(playerPrefab).transform;
        player          = playerContainer.Find("PlayerEnt").GetComponent <PlayerController>();
        playerUI        = playerContainer.Find("PlayerUI").GetComponent <PlayerHud>();
        playerSprites   = player.gameObject.GetComponentsInChildren <SpriteRenderer>();
        camera.setFollowing(player.gameObject);

        if (twoControllers)
        {
            player.setController(1);
        }
        else
        {
            player.setController(1);
        }
    }
示例#23
0
        public void Initialize(BotData data, PrimaryWeaponStats primary, SecondaryWeaponStats secondary, int playerId, Sprite face)
        {
            botStats       = data;
            primaryStats   = primary;
            secondaryStats = secondary;

            var huds = GameObject.Find("PlayerStats").GetComponent <PlayerHudManager>();

            playerHud = huds.GetPlayerHud(playerId);
            playerHud.LoadFace(face);

            floatHud = Instantiate(FloatingHudPf, Vector3.zero, Quaternion.identity).GetComponent <FloatingHud>();

            var secondaryDeplete = 1 / secondaryStats.EffectDuration * Time.deltaTime;

            floatHud.Initialize(primaryStats.AmmoCap, secondaryDeplete, playerId);
            floatHud.GetComponent <AnchorHud>().SetAnchor(this.transform);
        }
示例#24
0
    public Player(int id, string name, Vector2 position, Map m)
        : base(position, m)
    {
        playerID   = id;
        playerName = name;

        keyboard          = new KeyboardWatch();
        mouse             = new MouseWatch();
        mouse.Perspective = Map.GameCamera;

        float charHeight = 165f;
        float h          = (float)playerTileset.Height / charHeight;
        float w          = ((float)playerTileset.Width / playerTileset.Height);

        playerMesh         = sprite.Mesh;
        playerMesh.Tileset = playerTileset;

        playerMesh.Vertices2 = new Vector2[] {
            new Vector2(-0.5f * w * h, -0.5f + h),
            new Vector2(0.5f * w * h, -0.5f + h),
            new Vector2(0.5f * w * h, -0.5f),
            new Vector2(-0.5f * w * h, -0.5f)
        };

        playerMesh.UV = new Vector2[] {
            new Vector2(0, 1),
            new Vector2(1, 1),
            new Vector2(1, 0),
            new Vector2(0, 0)
        };

        shadow = new PlayerShadow(this, playerMesh);

        dashCooldown  = new Timer(stats.DashCooldown, false);
        dodgeCooldown = new Timer(stats.DodgeCooldown, true);

        hud = new PlayerHud(this);

        ownedWeapons.Add(WeaponList.Pistol);

        size = size * 1.4f;
    }
示例#25
0
    public static GameObject setHudElement(Transform t, String type, String name, int bind, RectTransform beside, float origSpaceNeeded)
    {
        if (type == "Other")
        {
            type = "Gun";             // For these purposes:
        }
        if (OptionsMenu.hudPanels.ContainsKey(type))
        {
            GameObject panel = MonoBehaviour.Instantiate(OptionsMenu.hudPanels[type]);

            // Ordered by add order
            float spaceNeeded = PlayerHud.getHudHeightUsed(t);

            panel.transform.SetParent(t, false);
            // This is a terrible way to set position, but it should work for now.
            if (type == "Cooldown" || type == "Trap" || type == "Gun" || type == "Other" || type == "Generic")               // Traps should probably give more information
            {
                panel.transform.Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [bind]) + ") " + name;
            }
            else if (type == "Icicle")
            {
                panel.transform.Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [bind]) + ")";
            }
            // Special case:
            if (type == "Gun3Modes")
            {
                panel.transform.Find("Gun1").Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [OptionsMenu.PRIMARY_1]) + ") " + name;
                panel.transform.Find("Gun2").Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [OptionsMenu.PRIMARY_2]) + ") Accurate-Fire";
                panel.transform.Find("Gun3").Find("Text").GetComponent <Text> ().text = "(" + OptionsMenu.getBindString(OptionsMenu.binds [OptionsMenu.PRIMARY_3]) + ") Conductive-Fire";
            }
            if (beside == null)
            {
                panel.GetComponent <RectTransform> ().anchoredPosition = new Vector2(panel.GetComponent <RectTransform> ().anchoredPosition.x, -280 + (int)(spaceNeeded - origSpaceNeeded));
            }
            else
            {
                panel.GetComponent <RectTransform> ().anchoredPosition = new Vector2(panel.GetComponent <RectTransform> ().anchoredPosition.x, beside.anchoredPosition.y);
            }
            return(panel);
        }
        return(null);
    }
示例#26
0
    void DrawPlayerHud(object sender, EventMsg msg)
    {
        var  u3DPlayer = sender as U3DSceneObject;
        bool exist     = false;

        for (int i = 0; i < _playerHuds.Count; i++)
        {
            if (_playerHuds[i].U3DSceneObject.Equals(u3DPlayer))
            {
                exist = true;
            }
        }
        if (!exist)
        {
            var newGo = CreateNew(_hudP.m_template_player_go);
            newGo.SetActive(true);
            var playerHud = new PlayerHud(newGo, u3DPlayer);
            _playerHuds.Add(playerHud);
        }
    }
示例#27
0
        public void CutSide(int side)
        {
            int oppositeSide = side % 2 == 0 ? (side + 1) : (side - 1);
            int axisCount    = sideCutsCount[side] + sideCutsCount[oppositeSide];

            if (axisCount < 9)
            {
                upperCutBlock.CutFace(side);
                lowerCutBlock.CutFace(side);
                sideCutsCount[side]++;
            }
            else
            {
                LoggingActivityPlayerBehavior.SetCanPerformAction(false);
                PlayerHud.ToggleQualityGame(true);
                QualityMinigame.StartGame();

                StartCoroutine(FallAfterGrade(side));
            }
        }
    /*
     * Remove one health unit from player and if health becomes 0, change
     * scene to the end game scene.
     */
    public void Damage()
    {
        health -= 1;

        if (health < 1)
        {
            //searches for the GameObject "EndingScore" and creates a reference through the ScoreText GameObject
            GameObject CanvasScript = GameObject.Find("Canvas");
            //Sets HighScore as a reference to the PlayerHud script
            PlayerHud HighScore = CanvasScript.GetComponent <PlayerHud>();
            //sets HighScoreIndex equal to the "HighScore Index" variable in PlayerPrefs
            HighScoreIndex = PlayerPrefs.GetInt("HighScore Index");
            //sets the "High Score" + HighScoreIndex variable in PlayerPrefs equal to the most recent score
            PlayerPrefs.SetFloat("High Score" + HighScoreIndex, HighScore.Score);
            //increments the HighScoreIndex by 1
            HighScoreIndex++;
            //sets the "HighScoreIndex" in PlayerPrefs equal to the HighScoreIndex
            PlayerPrefs.SetInt("HighScore Index", HighScoreIndex);
            //loads the scene "EndGame"
            SceneManager.LoadScene("EndGame");
        }
    }
    //function called when object attatched to script hits another object
    void OnTriggerEnter2D(Collider2D PlayerRemove)
    {
        //checks object hit for the tag "Player"
        if (PlayerRemove.tag == "Player")
        {
            //searches for the GameObject "Canvas" and creates a reference through the CanvasScript GameObject
            GameObject CanvasScript = GameObject.Find("Canvas");
            //Sets HighScore as a reference to the PlayerHud script
            PlayerHud HighScore = CanvasScript.GetComponent <PlayerHud>();

            //sets HighScoreIndex equal to the "HighScore Index" variable in PlayerPrefs
            HighScoreIndex = PlayerPrefs.GetInt("HighScore Index");
            //sets the "High Score" + HighScoreIndex variable in PlayerPrefs equal to the most recent score
            PlayerPrefs.SetFloat("High Score" + HighScoreIndex, HighScore.Score);
            //increments the HighScoreIndex by 1
            HighScoreIndex++;
            //sets the "HighScoreIndex" in PlayerPrefs equal to the HighScoreIndex
            PlayerPrefs.SetInt("HighScore Index", HighScoreIndex);
            //loads the scene "EndGame"
            SceneManager.LoadScene("EndGame");
        }
    }
示例#30
0
        public void SawLocation(int loc)
        {
            if (locationStrokeCounts[loc] == 0)
            {
                logMarks[loc].SetActive(false);
            }


            if (locationStrokeCounts[loc] < 5)
            {
                int cut01 = loc == 0 ? 0 : 2;
                int cut02 = loc == 0 ? 1 : 3;

                locationStrokeCounts[loc]++;
                sawProgressCuts[cut01].CutFace(3);
                sawProgressCuts[cut02].CutFace(3);
            }

            if (locationStrokeCounts[loc] == 5)
            {
                snapSpots[loc].enabled  = false;
                locationFullySawed[loc] = true;

                LoggingActivityPlayerBehavior.SetCanPerformAction(false);

                if (locationFullySawed[0] && locationFullySawed[1])
                {
                    PlayerHud.ToggleQualityGame(true);
                    QualityMinigame.StartGame();

                    StartCoroutine(SawThroughAfterGrade(loc));
                }
                else
                {
                    LoggingActivityPlayerBehavior.UnsnapPlayer();
                }
            }
        }