Ejemplo n.º 1
0
    void Awake()
    {
        // Initialize references to movement and shooting
        playerMovement = GetComponent <PlayerMovement> ();
        playerShooting = GetComponentInChildren <PlayerShooting> ();

        // Initialize reference to the health of other player to check for isDeadForever when determining if both players are dead
        otherPlayerHealth = otherPlayer.GetComponent <PlayerHealth> ();

        // Set health to starting health value determined (in this case, 100)
        currentHealth = startingHealth;

        // Initial access to the UI hearts representing life in the HUD Health UI
        lifeCount = lifeHearts.GetComponent <LifeCount> ();

        // Get player RigidBody and original position
        rb = GetComponent <Rigidbody> ();

        // Save original position
        originalSpawn = rb.transform.position;

        // Set as false since the player just started
        isDeadForever = false;
        isDead        = false;

        // Set initial lives count to 3
        lives          = 3;
        startingHealth = 100;
    }
Ejemplo n.º 2
0
    public IEnumerator RespawnPlayerCo()
    {
        //Creates death particle
        Instantiate(DeathParticle, Pc2.transform.position, Pc2.transform.rotation);
        //hide player
        //Player.enable = false;
        Pc2.SetActive(false);
        //Pc.GetComponent<Renderer>() .enabled = false;
        LifeCount.RemovePoints(PointsToRemove);
        // Gravity reset
        StoreGravity = Pc2.GetComponent <Rigidbody2D>().gravityScale;
        Pc2.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Pc2.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //point penalty
        ScoreManager.AddPoints(-DeathPenalty);
        //Debug Penailty
        Debug.Log("Player Respawn");
        yield return(new WaitForSeconds(RespawnDelay));

        Pc2.GetComponent <Rigidbody2D>().gravityScale = StoreGravity;
        Pc2.transform.position = CurrentCheckPoint.transform.position;
        Pc2.SetActive(true);
        //Pc.GetComponent<Renderer>() .enabled = true;
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     cam         = GameObject.Find("Main Camera").GetComponent <cameraInfo> ();
     myBehaviour = gameObject.GetComponent <PlayerBehaviour>();
     myLife      = gameObject.GetComponent <LifeCount>();
     createGhosts();
 }
    // Use this for initialization
    void Start()
    {
        //Create Begin text
        CreateBeginClone();

        //Create life text
        lifeCount = GameObject.FindObjectOfType <LifeCount>();
    }
Ejemplo n.º 5
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.GetComponent <Rigidbody2D>() == null)
        {
            return;
        }
        LifeCount.AddPoints(PointsToAdd);

        Destroy(gameObject);
    }
Ejemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        #region find objects of type bullet manager and life count
        //bullet manager
        bulletManager = GameObject.FindObjectOfType <BulletManagerScript>();

        //life count
        lifeCount = GameObject.FindObjectOfType <LifeCount>();

        //music player
        musicPlayer = GameObject.FindObjectOfType <MusicPlayer>();

        #endregion find objects of type bullet manager and life count

        Instantiate(formationList[0], new Vector3(8f, 6.5f, 0f), Quaternion.identity);
    }
Ejemplo n.º 7
0
    protected override void OnCreate()
    {
        Entity stateEntity = EntityManager.CreateEntity();

#if UNITY_EDITOR
        EntityManager.SetName(stateEntity, "GameState");
#endif

        GameState state = new GameState {
            CurrentPhase = GameState.Phase.Playing
        };
        EntityManager.AddComponentData(stateEntity, state);
        SetSingleton(state);

        LifeCount lifeCount = new LifeCount {
            Value = Config.Instance.StartingLives
        };
        EntityManager.AddComponentData(stateEntity, lifeCount);
        SetSingleton(lifeCount);

        resetQuery = GetEntityQuery(typeof(ResetLevelCommand));
    }
        public string HashCode()
        {
            // Salt the data
            string salt = "exWOhxnV2KLuSvOdE70k";
            string str  = salt.Substring(10) + LifeCount.ToString() + salt.Substring(0, 6) + InfiniteLives.GetHashCode().ToString() + salt.Substring(3, 8);

            // Create a SHA256 hash from salted data
            using (SHA256 sha256Hash = SHA256.Create())
            {
                // ComputeHash - returns byte array
                byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(str));

                // Convert byte array to a string
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < bytes.Length; i++)
                {
                    builder.Append(bytes[i].ToString("x2"));
                }

                return(builder.ToString());
            }
        }
Ejemplo n.º 9
0
    protected override void OnUpdate()
    {
        //todo this system does too many things I think

        // ideally we use RequireSingletonForUpdate but we want to cache an entity query
        // to avoid GC alloc, but doing so means I also need [AlwaysUpdateSystem]
        if (!HasSingleton <LifeCount>() || !HasSingleton <GameState>())
        {
            return;
        }

        // If query is empty, a ball exists, so we don't need to spawn one.
        if (!ballQuery.IsEmptyIgnoreFilter)
        {
            return;
        }

        LifeCount lifeCount = GetSingleton <LifeCount>();

        if (lifeCount.Value <= 0)
        {
            GameState state = GetSingleton <GameState>();
            state.CurrentPhase = GameState.Phase.Lost;
            SetSingleton(state);
            return;
        }

        lifeCount.Value--;
        SetSingleton(lifeCount);

        Entity request = EntityManager.CreateEntity();

        EntityManager.AddComponentData(request, new BallSpawnCommand
        {
            Position = new float2(0, -1f),
            Velocity = new float2(0, -9f)
        });
    }
Ejemplo n.º 10
0
    void Start()
    {
        Rigidbody2D rb = this.GetComponent <Rigidbody2D>();

        lifeCount = GameObject.FindGameObjectWithTag("lifeCounter").GetComponent <LifeCount>();
    }