Esempio n. 1
0
    private void Update()
    {
        PlayerValues player1 = PlayerValues.GetPlayer(0);

        if (player1 != null)
        {
            float x = player1.transform.position.x;
            float y = player1.transform.position.y;
            if (x > MaxX || x < MinX || y > MaxY || y < MinY)
            {
                player1.Die();
            }
        }
        PlayerValues player2 = PlayerValues.GetPlayer(1);

        if (player2 != null)
        {
            float x = player2.transform.position.x;
            float y = player2.transform.position.y;
            if (x > MaxX || x < MinX || y > MaxY || y < MinY)
            {
                player2.Die();
            }
        }
    }
Esempio n. 2
0
    private void Start()
    {
        PlayerVfx             = transform.Find("PlayerVfx");
        PlayerBase            = GetComponentInParent <PlayerBase>();
        PlayerGroundDetection = GetComponentInParent <PlayerGroundDetection>();
        PlayerValues          = Resources.Load <PlayerValues>("Settings/PlayerValues");

        switchDashInt = -1;
        switchLandInt = -1;
        switchJumpInt = -1;

        quarterDashTime = PlayerValues.dashTime / 4;
        ps_pos_left     = ps_landL_large_1.transform.localPosition;
        ps_pos_right    = ps_landR_large_1.transform.localPosition;
        var ps_dash1_1_main = ps_dash1_1.main;
        var ps_dash2_1_main = ps_dash2_1.main;
        var ps_dash3_1_main = ps_dash3_1.main;
        var ps_dash1_2_main = ps_dash1_2.main;
        var ps_dash2_2_main = ps_dash2_2.main;
        var ps_dash3_2_main = ps_dash3_2.main;

        ps_dash1_1_main.startColor = ps_dash_startColor;
        ps_dash2_1_main.startColor = ps_dash_startColor;
        ps_dash3_1_main.startColor = ps_dash_startColor;
        ps_dash1_2_main.startColor = ps_dash_startColor;
        ps_dash2_2_main.startColor = ps_dash_startColor;
        ps_dash3_2_main.startColor = ps_dash_startColor;
    }
Esempio n. 3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        PlayerValues player = other.gameObject.GetComponent <PlayerValues>();

        if (player != null)
        {
            player.Die();
            Destroy(gameObject, 0.5f);
        }
//        if(player == null || player.IsPlayerDead)
//        {
//            Destroy(this.gameObject);
//        }

        //if (other.gameObject.name == "Player 1")
        //{
        //    player.GetComponent<PlayerValues>().Die();
        //    Destroy(this.gameObject, 0.5f);
        //}

        //else if (other.gameObject.name == "Player 2")
        //{
        //    player2.GetComponent<PlayerValues>().Die();

        //    Destroy(this.gameObject, 0.5f);
        //}
    }
Esempio n. 4
0
    void Start()
    {
        // If AI is dodged constantly it will "time out" and die after 15 seconds.
        Destroy(this.gameObject, 15f);
        StartCoroutine(TimeOut(10));

        player  = GameObject.FindGameObjectWithTag("Player");
        player2 = GameObject.FindGameObjectWithTag("Player2");

        PickupManager manager            = FindObjectOfType <PickupManager>();
        int           currentPickupOwner = manager.GetCurrentPickupOwner();

        if (currentPickupOwner == 0)
        {
            target = PlayerValues.GetPlayer(1)?.transform;
        }
        else
        {
            target = PlayerValues.GetPlayer(0)?.transform;
        }
        animator.SetBool("Targeted", true);
        target.GetComponent <PlayerValues>()?.SetTargeted(true);
        //if (Player1PickedUpTheThing == true)
        //{
        //target = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
    }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     canvasController = GameObject.Find("MainCanvas").GetComponent <CanvasController>();
     player           = GameObject.Find("Player").transform;
     playerValues     = player.GetComponent <PlayerValues>();
     nav = GetComponent <UnityEngine.AI.NavMeshAgent>();
 }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     influenceProtocols = FindObjectOfType <InfluenceProtocols> ().GetComponent <InfluenceProtocols> ();
     playerValues       = FindObjectOfType <PlayerValues> ().GetComponent <PlayerValues> ();
     statusText         = FindObjectOfType <StatusText> ().GetComponent <StatusText> ();
     this.gameObject.SetActive(false);
 }
    void SaveData()
    {
        FileStream file = null;

        try
        {
            BinaryFormatter bf = new BinaryFormatter();

            file = File.Create(Application.persistentDataPath + DATA_PATH);

            PlayerValues p = new PlayerValues();

            bf.Serialize(file, p);
        } catch (Exception e)
        {
            if (e != null)
            {
                //handle exception
            }
        } finally
        {
            if (file != null)
            {
                file.Close();
            }
        }
    }
    void LoadData()
    {
        FileStream file = null;

        try
        {
            BinaryFormatter bf = new BinaryFormatter();

            file = File.Open(Application.persistentDataPath + DATA_PATH, FileMode.Open);

            playerValues = bf.Deserialize(file) as PlayerValues;
        }
        catch (Exception e)
        {
            if (e != null)
            {
            }
        } finally
        {
            if (file != null)
            {
                file.Close();
            }
        }
    }
Esempio n. 9
0
        /// <param name="moviePath">Path to the movie. Format here varies based on location.</param>
        /// <param name="fileLocation">What file or folder the given path is relative to.</param>
        public override bool SetValues(PlayerValues values)
        {
            _mediaPlayer = gameObject.GetComponent <RenderHeads.Media.AVProVideo.MediaPlayer>();
            if (_mediaPlayer == null)
            {
                // no media component already added to this component, try adding a MediaPlayer component
                try
                {
                    _mediaPlayer = gameObject.AddComponent <RenderHeads.Media.AVProVideo.MediaPlayer>();
                }
                catch (Exception e)
                {
                    Debug.LogError("AVProVideo not found in project: " + e.ToString());
                    return(false);
                }
            }

            //disable autoplay and autoload, which are on by default
            _mediaPlayer.m_AutoStart = false;
            _mediaPlayer.m_AutoOpen  = false;

            //relies on exact parity between enum values in AVProVideo and Clip
            _mediaPlayer.m_VideoLocation = (RenderHeads.Media.AVProVideo.MediaPlayer.FileLocation)((int)values.location);

            if (values.moviePath != "")
            {
                //cache the movie path reference
                _mediaPlayer.m_VideoPath = values.moviePath;
                return(true);
            }

            return(false);
        }
Esempio n. 10
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (_triggered)
        {
            return;
        }
        PlayerValues player = other.GetComponent <PlayerValues>();

        if (player == null)
        {
            return;
        }

        _triggered = true;
        try
        {
            OnPickup.Invoke(player.Id);
        }
        catch (Exception e)
        {
            Debug.LogError(e);
        }

        Destroy(gameObject);
    }
Esempio n. 11
0
    /***LOGIC METHODS ***/
    private float getMoveVel(PlayerValues.inputState currentInputState)
    {
        switch (currentInputState) {

        case PlayerValues.inputState.WalkLeft:{
            return -values.walkVel;
        }

        case PlayerValues.inputState.WalkRight:{
            return values.walkVel;
        }

        case PlayerValues.inputState.RunLeft:{
            return -values.runVel;
        }

        case PlayerValues.inputState.RunRight:{
            return values.runVel;
        }
        case PlayerValues.inputState.None:
        default:
            return 0f;

        }
    }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     playerValues = FindObjectOfType <PlayerValues> ().GetComponent <PlayerValues> ();
     animator     = GetComponent <Animator> ();
     if (!playerValues.dayStart)
     {
         if (playerValues.enemyGotUp)
         {
             enemyGotUp = true;
         }
         if (enemyGotUp)
         {
             animator.SetTrigger("AlreadyOffscreen");
         }
     }
     else
     {
         playerValues.dayStart = false;
         if (playerValues.enemyGotUp)
         {
             //animator.SetTrigger ("AlreadyAtDesk");
             enemyGotUp = false;
             playerValues.enemyGotUp = false;
         }
         playerValues.timeSinceLastBreak  = 0;
         playerValues.timeSinceEnemyGotUp = 0;
     }
 }
Esempio n. 13
0
    private void Start()
    {
        PlayerBase   = GetComponent <PlayerBase>();
        PlayerValues = Resources.Load <PlayerValues>("Settings/PlayerValues");

        grounded            = true;
        releasePlatformTime = PlayerValues.coyoteTime;
    }
Esempio n. 14
0
 private void Start()
 {
     GameManager.OnLivesChanged += UpdatePlayerLives;
     UpdatePlayerLives();
     _killPlayer1Button?.onClick.AddListener(() => PlayerValues.GetPlayer(0)?.Die());
     _killPlayer2Button?.onClick.AddListener(() => PlayerValues.GetPlayer(1)?.Die());
     _resetLivesButton?.onClick.AddListener(GameManager.ResetLives);
 }
Esempio n. 15
0
 public void loadStats(PlayerValues player)
 {
     player.currentXP     = exp;
     player.hpFlaskAmount = potions;
     player.setLevel(level);
     FindObjectOfType <CharSheetController>().updateStats();
     FindObjectOfType <CombatManager>().xpText.text = "XP " + player.getXP() + "/" + player.getXPForLevel(player.getLevel());
 }
Esempio n. 16
0
 public SavefileDisplayData(PlayerValues playerValues, TimeManager timeManager)
 {
     hp       = playerValues.healthPoints;
     gaia     = playerValues.gaia;
     ga       = playerValues.currency;
     location = playerValues.currentOWScene;
     playtime = timeManager.GetTimeHoursSeconds();
 }
Esempio n. 17
0
    private void Start()
    {
        rb             = GetComponent <Rigidbody2D>();
        playerRaycasts = GetComponent <PlayerRaycasts>();
        playerValues   = Resources.Load <PlayerValues>("Settings/PlayerValues");

        PlayerStartLogic();
    }
    //find own ridigbody, the player-object and other scripts
    private void Awake()
    {
        minionRigidbody = GetComponent <Rigidbody>();

        minionControlScript = GetComponent <MinionControl>();

        target             = GameObject.Find("Player").transform;
        playerValuesScript = target.gameObject.GetComponent <PlayerValues>();
    }
Esempio n. 19
0
 // Use this for initialization
 void Start()
 {
     playerValues            = FindObjectOfType <PlayerValues> ().GetComponent <PlayerValues> ();
     playerValues.interScene = false;
     musicManagerSource      = FindObjectOfType <MusicManager> ().GetComponent <AudioSource> ();
     if (!musicManagerSource.isPlaying)
     {
         musicManagerSource.Play();
     }
 }
Esempio n. 20
0
    // Use this for initialization
    void Start()
    {
        animator     = GetComponent <Animator> ();
        playerValues = FindObjectOfType <PlayerValues> ().GetComponent <PlayerValues> ();

        if (!playerValues.playersComputer)
        {
            animator.SetTrigger("AlreadyAtEnemyDesk");
        }
    }
Esempio n. 21
0
 void Start()
 {
     difficultyLevel  = PlayerPrefs.GetInt("difficultyLevel", 0);
     player           = GameObject.Find("Player");
     playerVal        = player.GetComponent <PlayerValues>();
     spawnEnemies     = player.GetComponent <SpawnEnemies>();
     metersWalkedText = GameObject.Find("InGameCanvas/MetersWalked").GetComponent <Text>();
     recordText       = GameObject.Find("StartCanvas/Record");
     GameObject.Find("WeaponsCanvas/DifficultyLevel").GetComponent <Text>().text = difficultyLevel.ToString();
 }
Esempio n. 22
0
 void Start()
 {
     GAME      = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController> ();
     ShieldObj = transform.FindChild("ForceField").gameObject;
     //GetComponent<Animator> ().SetBool ("Weapon", true);
     anim = GetComponent <Animator> ();
     anim.SetInteger("WeaponType", 0);
     Values = GetComponent <PlayerValues> ();
     anim   = GetComponent <Animator> ();
 }
Esempio n. 23
0
    // Use this for initialization
    void Start()
    {
        player        = GameObject.Find("Player");
        playerValues  = player.GetComponent <PlayerValues>();
        pistolValues  = playerValues.GetPistolValues();
        minigunValues = playerValues.GetMinigunValues();

        pistolFrequency  = 1.0f / pistolValues[4];
        minigunFrequency = 1.0f / minigunValues[4];
    }
Esempio n. 24
0
 private void instantiateHelperClasses()
 {
     this.playerValues = new PlayerValues();
     this.instantiateRoadManager();
     this.topShoulder                        = new Shoulder(this.player.Width);
     this.animationManager                   = new AnimationManager();
     this.collisionDetector                  = new CollisionDetector();
     this.lifeTimer                          = new LifeTimer();
     this.playerMovementManager              = new PlayerMovementManager(this.player, this.FrogHomes);
     this.playerMovementManager.PlayerMoved += this.playerMoved;
 }
Esempio n. 25
0
    // Use this for initialization
    void Start()
    {
        playerAnimator = FindObjectOfType <Player> ().GetComponentInChildren <Animator> ();
        playerValues   = FindObjectOfType <PlayerValues> ().GetComponent <PlayerValues> ();
        bossAnimator   = GetComponent <Animator> ();

        if (playerValues.gameFirstStart || playerValues.gameOver)
        {
            Invoke("BossWalksIn", 3);
        }
    }
Esempio n. 26
0
 override protected void Awake()
 {
     base.Awake();
     //objectCollider = transform.parent.GetComponent<BoxCollider>();
     playerValues         = GetComponent <PlayerValues>();
     countdown            = dashCooldown;
     DashCooldownTimer    = new BasicTimer(dashCooldown);
     DashDurationTimer    = new BasicTimer(dashDuration);
     IsWithinTriggerRange = false;
     DashLevel            = 1;
 }
Esempio n. 27
0
 private void Start()
 {
     playerVal        = GameObject.Find("Player").GetComponent <PlayerValues>();
     originalPosition = transform.position;
     destination      = new Vector3(Random.Range(-2.0f, 2.0f), transform.position.y, transform.position.z + 20);
     angle            = AngleInDeg(originalPosition, destination);
     halfDistance     = calculateDistance(originalPosition, destination) / 2;
     halfZpoint       = originalPosition.z + halfDistance;
     tempFloat        = 0.1f;
     transform.Rotate(0, angle / 3, 0);
 }
Esempio n. 28
0
    //initialization
    private void Start()
    {
        Application.targetFrameRate = 60;
        QualitySettings.vSyncCount  = 1;

        collisionBox.layerMask = 1 << LayerMask.NameToLayer("Ground") | 1 << LayerMask.NameToLayer("Objects");

        player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerValues>();

        hpText.text = "HP " + player.getHP().ToString() + "/" + player.getFullHP();
    }
Esempio n. 29
0
    // Use this for initialization
    void Start()
    {
        debugResetButton.gameObject.SetActive(false);
        kidValues          = FindObjectOfType <KidValues>().GetComponent <KidValues>();
        kid                = FindObjectOfType <Kid>().GetComponent <Kid>();
        playerValues       = FindObjectOfType <PlayerValues>().GetComponent <PlayerValues>();
        currentKidAnimator = currentKidObject.GetComponentInChildren <Animator>();
        sfxManager         = FindObjectOfType <SFXManager>().GetComponent <SFXManager>();
        musicManager       = FindObjectOfType <MusicManager>().GetComponent <MusicManager>();

        RandomizeKid();
    }
Esempio n. 30
0
 void Start()
 {
     player                    = GameObject.Find("Player");
     playerVal                 = player.GetComponent <PlayerValues>();
     instantiatedPrefabs       = new List <GameObject>();
     navigationBarImage        = GameObject.Find("NavigationBar").GetComponent <Image>();
     cnbDescriptionText        = GameObject.Find("NavigationBar/CNBDescription").GetComponent <Text>();
     chooseAndBuyText          = GameObject.Find("NavigationBar/ChooseAndBuyText").GetComponent <Text>();
     secondaryWeaponController = player.GetComponent <SecondaryWeaponController>();
     skillsController          = player.GetComponent <SkillsController>();
     GetAllData();
 }
Esempio n. 31
0
    private void SpawnPlayer(int id)
    {
        GameObject   instance     = Instantiate(_playerPrefab, PlayerSpawnPoints.Length > id ? PlayerSpawnPoints[id] : GetRandomSpawnPoint(), Quaternion.identity);
        PlayerValues playerValues = instance.GetComponent <PlayerValues>();

        playerValues.Id         = id;
        playerValues.Invincible = true;
        instance.GetComponent <PlayerMovement>().RewiredId        = id;
        instance.GetComponentInChildren <SpriteRenderer>().sprite = id == 0 ? _player1Sprite : _player2Sprite;
        //Temp
        //  instance.GetComponentInChildren<SpriteRenderer>().color = id == 0 ? Color.blue : Color.red;
    }
Esempio n. 32
0
        public FreeForAll(Color[] colors, string mapString, float gravity, int minutes, int lives, float limbStrength, bool suddenDeath, bool traps, bool longRange, bool bots)
        {
            world = new World(new Vector2(0, gravity));

            MapData data = Map.LoadMap(world, mapString);
            background = data.background;
            walls = data.walls;
            spawnPoints = data.spawnPoints;
            Vector3[] ammoPoints = data.ammoPoints;
            ammo = new TrapAmmo[ammoPoints.Length];
            if (traps)
                for (int i = 0; i < ammoPoints.Length; i++)
                    ammo[i] = new TrapAmmo(world, new Vector2(ammoPoints[i].X, ammoPoints[i].Y) * MainGame.PIXEL_TO_METER, (int)ammoPoints[i].Z);
            music = data.music;
            MediaPlayer.Play(music);
            foreground = data.foreground;

            StickFigure.AllowTraps = traps;
            StickFigure.AllowLongRange = longRange;

            player = new StickFigure[bots ? 4 : colors.Length];
            this.info = new PlayerValues[bots ? 4 : colors.Length];

            for (int i = 0; i < colors.Length; i++)
                if (colors[i] != null)
                {
                    player[i] = new LocalPlayer(world, spawnPoints[i] * MainGame.PIXEL_TO_METER, Categories[i], 1.5f, limbStrength, suddenDeath ? 0.001f : 1f, false, colors[i], Players[i]);
                    player[i].LockControl = true;
                }

            if (bots && colors.Length < 4)
            {
                for (int i = colors.Length; i < 4; i++)
                {
                    player[i] = new BotPlayer(world, spawnPoints[i] * MainGame.PIXEL_TO_METER, Categories[i], 1.5f, limbStrength, suddenDeath ? 0.001f : 1f, false, new Color(i * 60, i * 60, i * 60), Players[i], player);
                    player[i].LockControl = true;
                }
            }

            for (int i = 0; i < info.Length; i++)
                info[i] = new PlayerValues(lives);

            timed = minutes > 0;
            millisLeft = (minutes == 0 ? -1 : minutes * 60000);
            startPause = 180;
            gameOver = false;
            winners = new List<int>();
            winSticks = new List<StickFigure>();
            enterPressed = true;
        }
Esempio n. 33
0
    public void Initialize()
    {
        GameObject gTeam = GameObject.FindGameObjectWithTag("Player Team");
        Team team = gTeam.GetComponent<Team>();
        m_myTeam = team.m_teamNumber;

        // Cache the global storage for health data
        GameObject healthValues = GameObject.Find ("Player Values");
        m_manaPool = healthValues.GetComponent<PlayerValues>();

        m_allyPercentages = m_manaPool.GetMyTeamMP(Network.player, out m_myTeam);
        m_enemyPercentages = m_manaPool.GetOppTeamMP(m_myTeam);

        initialized = true;
    }
        public TeamDeathmatch(Color[] colors, string mapString, float gravity, int minutes, int lives, float limbStrength, bool suddenDeath, bool traps, bool longRange, bool bots)
        {
            world = new World(new Vector2(0, gravity));

            object[] map = Map.LoadMap(world, mapString);
            background = (Texture2D)map[0];
            walls = (List<Wall>)map[1];
            spawnPoints = (Vector2[])map[2];
            Vector3[] ammoPoints = (Vector3[])map[3];
            ammo = new TrapAmmo[ammoPoints.Length];
            if (traps)
                for (int i = 0; i < ammoPoints.Length; i++)
                    ammo[i] = new TrapAmmo(world, new Vector2(ammoPoints[i].X, ammoPoints[i].Y) * MainGame.PIXEL_TO_METER, (int)ammoPoints[i].Z);

            StickFigure.AllowTraps = traps;
            StickFigure.AllowLongRange = longRange;

            player = new StickFigure[bots ? 4 : colors.Length];
            this.info = new PlayerValues[bots ? 4 : colors.Length];

            for (int i = 0; i < colors.Length; i++)
                if (colors[i] != null)
                {
                    player[i] = new LocalPlayer(world, spawnPoints[i] * MainGame.PIXEL_TO_METER, Categories[i], 1.5f, limbStrength, suddenDeath ? 0.001f : 1f, i % 2 == 1, colors[i], Players[i]);
                    player[i].LockControl = true;
                }

            if (bots && colors.Length < 4)
            {
                for (int i = colors.Length; i < 4; i++)
                {
                    player[i] = new BotPlayer(world, spawnPoints[i] * MainGame.PIXEL_TO_METER, Categories[i], 1.5f, limbStrength, suddenDeath ? 0.001f : 1f, i % 2 == 1, new Color(i * 60, i * 60, i * 60), Players[i], player);
                    player[i].LockControl = true;
                }
            }

            for (int i = 0; i < info.Length; i++)
                info[i] = new PlayerValues(lives);

            timed = minutes > 0;
            millisLeft = (minutes == 0 ? -1 : minutes * 60000);
            startPause = 180;
            gameOver = false;
            winners = new List<int>();
            winSticks = new List<StickFigure>();
        }
Esempio n. 35
0
 private float getIncreasedFallVell(PlayerValues.inputState currentInputState)
 {
     if (_rigidbody.velocity.y < 0)
     {
         if (currentInputState == PlayerValues.inputState.Fall) {
                 return 1.02f;
         } else if (currentInputState == PlayerValues.inputState.Float) {
                 return  .99f;
         } else {
                 return 1f;
         }
     }
     else
     {
         if (currentInputState == PlayerValues.inputState.Fall) {
             return .98f;
         } else if (currentInputState == PlayerValues.inputState.Float) {
             return  1.02f;
         } else {
             return 1f;
         }
     }
 }
Esempio n. 36
0
    public void Initialize()
    {
        GameObject gTeam = GameObject.FindGameObjectWithTag("Player Team");
        Team team = gTeam.GetComponent<Team>();
        m_myTeam = team.m_teamNumber;

        // Cache the global storage for health data
        GameObject healthValues = GameObject.Find ("Player Values");
        m_healthPool = healthValues.GetComponent<PlayerValues>();

        m_allyPercentages = m_healthPool.GetMyTeamHP(Network.player, out m_myTeam);
        m_enemyPercentages = m_healthPool.GetOppTeamHP(m_myTeam);

        initialized = true;

        /*// Get the PlayerDataManager script so that we can get its data on players
        GameObject playerManager = GameObject.Find("Player Data Manager");
        PlayerDataManager manager = playerManager.GetComponent<PlayerDataManager>();

        // Get the player's team number
        int myTeam = -1;
        myTeam = manager.GetTeam(Network.player);
        Debug.Log("Player has a team: " + (myTeam != -1));

        // Get the ally team's Health information
        PlayerContainer[] temp = manager.GetMyTeam(myTeam);
        if(temp != null) {
            Debug.Log ("Temp is not null, player has a team");
            List<Health> tempHp = new List<Health>();
            for(int i=0; i<temp.Length; i++) {
                if(temp[i] != null) {
                    // Force this player into the first position of the array and everyone else
                    // in the order in which they are were added in the PlayerDataManager
                    if(temp[i].m_player == Network.player) {
                        Debug.Log ("Added");
                        tempHp.Insert(0, temp[i].m_health);
                    } else {
                        Debug.Log ("Added");
                        tempHp.Add(temp[i].m_health);
                    }
                }
            }
            m_allyHp = tempHp.ToArray();
            m_allyPercentages = new float[m_allyHp.Length];
            tempHp.Clear();
            tempHp.TrimExcess();
        } else {
            Debug.Log("Bad team number given, no ally team data returned.");
        }

        // Get the other team's Health information
        /*temp = manager.GetEnemyTeam(myTeam);
        if(temp[0] != null) {
            List<Health> tempHp = new List<Health>();
            for(int i=0; i<temp.Length; i++) {
                if(temp[i] != null) {
                    Debug.Log ("Added");
                    tempHp.Add(temp[i].m_health);
                }
            }
            m_enemyHp = tempHp.ToArray();
            m_enemyPercentages = new float[m_enemyHp.Length];
        } else {
            Debug.Log("No enemy team data returned.");
        }

        initialized = true;

        // Calculate everyone's health
        CalculateHealthPercentages();*/
    }
Esempio n. 37
0
 public virtual void Awake()
 {
     _transform = transform;
     _rigidbody = GetComponent<Rigidbody2D>();
     values = new PlayerValues ();
 }
Esempio n. 38
0
    public void OnServerRecieveTeamChoice(NetworkMessage msg)
    {
        TeamChoice teamChoice = msg.ReadMessage<TeamChoice>();
        int choice = teamChoice.teamChoice;
         int idVal = ipToId(msg.conn.address, msg.conn.connectionId);
        if (!pm.checkIfExists(idVal)) {
            Debug.LogError("ID DOES NOT EXISTS, CONN IS "+msg.conn.connectionId);
            return;
        }
         int team = pm.getTeam(idVal);

        // if the player is choosing the team for the first time
        if (team == TeamID.TEAM_NEUTRAL){
            // update the team and send updated list to all clients

            pm.setTeam(idVal, choice);
            teamManager.addPlayerToTeam(pm.getName(idVal), choice);

            sendTeam (choice);

        } else if (pm.getTeam(idVal) != choice) {	// if the player has switched teams
            // delete player from old list and send updated list to all clients
            teamManager.deletePlayer(pm.getName(idVal), pm.getTeam(idVal));
            sendTeam (pm.getTeam(idVal));

            // add player to new team and send updated list to clients
            pm.setTeam(idVal, choice);
            teamManager.addPlayerToTeam(pm.getName(idVal), choice);
            sendTeam (choice);
        }

        //Send changes to the observers
        PlayerValues pv = new PlayerValues();
        pv.dictId = idVal;
        pv.oldId = idVal;
        pv.connVal = msg.conn.connectionId;
        pv.playerIP = msg.conn.address;
        pv.playerName = name;
        pv.playerTeam = choice;
        foreach (NetworkConnection nc in getUpdateListeners()){
            NetworkServer.SendToClient(nc.connectionId, Msgs.updatePlayerToObserver, pv); //Sends player info to the client that re-connected
        }
    }
Esempio n. 39
0
    public void OnServerRecieveName(NetworkMessage msg)
    {
        JoinMessage joinMsg = msg.ReadMessage<JoinMessage>();
        string name = joinMsg.name;
        int teamChoice = joinMsg.team;
        string address = msg.conn.address;
        int idValue = ipToId(address, msg.conn.connectionId);
        //If the player has already connected, set connected to true and update conn value
        int idValOld = pm.findPlayerWithIP(address); //Finds a player with the IP. Will return the latest player made and their identity if multiple exist
        if (((idValOld != -10)&&(!allowSharedIPs)) || ((pm.checkIfExists(idValue))&&(allowSharedIPs))){ //-10 means not found. If it was found, adjust old player
            Debug.LogError("Player " + idValOld + " exists, setting connected once more");
            Debug.LogError("connected state is " + pm.isConnected(idValOld));
            pm.setNewID(idValOld, idValue); //Makes new id connection based off new conn id
            pm.setConnected(idValue); //Indicate player is again connected
            pm.setConnValue(idValue, msg.conn.connectionId); //Updates old conn value
            pm.setNetworkConnection(idValue, msg.conn);

            PlayerValues pv = new PlayerValues();
            pv.dictId = idValue;
            pv.oldId = idValOld;
            pv.connVal = msg.conn.connectionId;
            pv.playerIP = address;
            pv.playerName = name;
            pv.playerTeam = teamChoice;
            NetworkServer.SendToClient(msg.conn.connectionId, Msgs.addNewPlayer, pv);
            if (teamChoice == TeamID.TEAM_OBSERVER)
            { //Checks if player is indicated as an observer. If so adds to observers list
                observingListeners.Add(msg.conn);
            }
            else
            {//If it's not an observer, inform observers
                foreach (NetworkConnection nc in getUpdateListeners())
                {
                    NetworkServer.SendToClient(nc.connectionId, Msgs.updatePlayerToObserver, pv); //Sends player info to the client that re-connected
                }
            }

        } else { //If is entirely new player
            Debug.Log("New player "+ address + ", given id" + idValue + ", offering team " + teamChoice);
            Player newPlayer = new Player(idValue, msg.conn.connectionId, address, name, teamChoice);

            pm.addPlayer(idValue, newPlayer);
            pm.setConnected(idValue); //Indicate player is again connected
            pm.setConnValue(idValue, msg.conn.connectionId); //Updates old conn value
            pm.setNetworkConnection(idValue, msg.conn);

            PlayerValues pv = new PlayerValues();
            pv.dictId = idValue;
            pv.connVal = msg.conn.connectionId;
            pv.playerIP = address;
            pv.playerName = pm.getName(idValue);
            pv.playerTeam = pm.getTeam(idValue);
            NetworkServer.SendToClient(msg.conn.connectionId, Msgs.addNewPlayer, pv); //Sends player info to the client that re-connected
            if (teamChoice == TeamID.TEAM_OBSERVER)
            { //Checks if player is indicated as an observer. If so adds to observers list
                observingListeners.Add(msg.conn);
            }
            else
            {//If it's not an observer, inform observers
                foreach (NetworkConnection nc in getUpdateListeners())
                {
                    NetworkServer.SendToClient(nc.connectionId, Msgs.addNewPlayerToObserver, pv); //Sends player info to the client that re-connected
                }
            }
            //NEED TO UPDATE OBSERVER'S INFORMATION AS WELL, AS THIS MAY OCCUR MID-GAME
        }
    }
Esempio n. 40
0
 public ScreanInput(PlayerValues val, GUIText GUI)
 {
     playerVal = val;
     this.gui = GUI;
 }
Esempio n. 41
0
 public ScreanInput(PlayerValues val)
 {
     playerVal = val;
 }
Esempio n. 42
0
        public SingleMap(Color[] colors, string mapString, float gravity, int lives, float limbStrength, bool suddenDeath, bool traps, bool longRange, bool bots)
        {
            world = new World(new Vector2(0, gravity));
            this.limbStrength = limbStrength;
            this.suddenDeath = suddenDeath;

            MapData data = Map.LoadMap(world, mapString);
            background = data.background;
            walls = data.walls;
            spawnPoints = data.spawnPoints;
            Vector3[] ammoPoints = data.ammoPoints;
            ammo = new TrapAmmo[ammoPoints.Length];
            if (traps)
                for (int i = 0; i < ammoPoints.Length; i++)
                    ammo[i] = new TrapAmmo(world, new Vector2(ammoPoints[i].X, ammoPoints[i].Y) * MainGame.PIXEL_TO_METER, (int)ammoPoints[i].Z);
            music = data.music;
            MediaPlayer.Play(music);
            foreground = data.foreground;

            StickFigure.AllowTraps = traps;
            StickFigure.AllowLongRange = longRange;

            player = new StickFigure[bots ? 4 : colors.Length];
            this.info = new PlayerValues[bots ? 4 : colors.Length];
            enemies = new List<StickFigure>();
            toRemove = new Dictionary<StickFigure, int>();
            temp = new List<StickFigure>();
            winStick = null;

            for (int i = 0; i < colors.Length; i++)
                if (colors[i] != null)
                {
                    player[i] = new LocalPlayer(world, spawnPoints[i] * MainGame.PIXEL_TO_METER, Category.Cat1, 1.5f, limbStrength, suddenDeath ? 0.001f : 1f, false, colors[i], Players[i]);
                    player[i].LockControl = true;
                }

            for (int i = 0; i < info.Length; i++)
                info[i] = new PlayerValues(lives);

            maxEnemies = player.Length;
            kills = 0;
            millis = 0;
            startPause = 180;
            gameOver = false;
            enterPressed = true;
        }
 public InplutHandlerKeyboard(PlayerValues val)
 {
     playerVal = val;
 }
 public PlayerAnimationHandler(Animator a, PlayerValues val)
 {
     anim = a;
     values = val;
 }