Ejemplo n.º 1
0
 public static void OnPlayerDied(Player player)
 {
     if (PlayerDied != null)
     {
         PlayerDied.Invoke(player);
     }
 }
Ejemplo n.º 2
0
    private IEnumerator ExplodeAndDie()
    {
        if (Linking.Count > 0)
        {
            for (int i = 0; i < Linking.Count; i++)
            {
                ExplosionManager.SpawnExplosion(Linking[i].Coordinates);

                yield return(new WaitForSeconds(0.07f));
            }

            SetCurrentVertex(Linking.First());
        }
        else
        {
            ExplosionManager.SpawnExplosion(transform.position);

            yield return(new WaitForSeconds(0.1f));
        }

        if (CurrentLine != null)
        {
            Destroy(CurrentLine.gameObject);
        }

        CurrentLine = null;
        Linking.Clear();

        _isDying = false;

        PlayerDied?.Invoke();
    }
Ejemplo n.º 3
0
 void FlagLevelLoad()
 {
     if (Time.time > this.startTime + player.deathTime)
     {
         PlayerDied.Invoke();
     }
 }
Ejemplo n.º 4
0
        public static void HandleData(GetDataEventArgs args, MemoryStream data, PvPPlayer player)
        {
            switch (args.MsgID)
            {
            case PacketTypes.PlayerHurtV2:
                PlayerHurt?.Invoke(typeof(DataHandler), new PlayerHurtArgs(args, data, player));
                return;

            case PacketTypes.TogglePvp:
                PvPToggled?.Invoke(typeof(DataHandler), new TogglePvPArgs(player));
                return;

            case PacketTypes.PlayerSlot:
                PlayerSlotUpdated?.Invoke(typeof(DataHandler), new PlayerSlotArgs(data, player));
                return;

            case PacketTypes.PlayerDeathV2:
                PlayerDied?.Invoke(typeof(DataHandler), new PlayerDeathArgs(player));
                return;

            case PacketTypes.ProjectileNew:
                ProjectileNew?.Invoke(typeof(DataHandler), new ProjectileNewArgs(args, data, player));
                return;

            case PacketTypes.ProjectileDestroy:
                ProjectileDestroyed?.Invoke(typeof(DataHandler), new ProjectileDestroyArgs(data));
                return;

            case PacketTypes.PlayerUpdate:
                PlayerUpdated?.Invoke(typeof(DataHandler), new PlayerUpdateArgs(data, player));
                return;
            }
        }
Ejemplo n.º 5
0
    public void Die()
    {
        PlayerDied?.Invoke();
        Destroy(gameObject);
        int deaths = PlayerPrefs.GetInt("Deaths");

        PlayerPrefs.SetInt("Deaths", deaths + 1);
    }
Ejemplo n.º 6
0
 public void ApplyDamage(int damage)
 {
     Lifes -= damage;
     if (Lifes <= 0)
     {
         PlayerDied?.Invoke();
     }
 }
Ejemplo n.º 7
0
 private void OnPlayerDie()
 {
     _player.Died -= OnPlayerDie;
     
     _isDied = true;
     _spawnDelay = SpawnDelay;
     
     PlayerDied?.Invoke();
 }
Ejemplo n.º 8
0
        private void OnPlayerDied(object sender, PlayerDiedEventArgs eventArgs)
        {
            playersWaitingForNextRound.Add(eventArgs.DeadPlayer);
            players.Remove(eventArgs.DeadPlayer);

            PlayerDied playerDiedGameEvent = new PlayerDied(eventArgs.DeadPlayer.Id);

            OnGameEventOccured?.Invoke(this, new GameEventOccuredEventArgs(playerDiedGameEvent, eventArgs.DeadPlayer.Id));
        }
Ejemplo n.º 9
0
    public virtual void Die()
    {
        GameManager.instance.screenUIController.gameResultUIController.ShowGameResultUI(false);
        GameManager.instance.screenUIController.playerUIController.OnDisable();

        PlayerDied?.Invoke(this);
        contactCollider.enabled = false;

        AnimationController.SetAnimationParameter(PlayerAnimatorParameter.Die); //AnimationController.SetDie();
    }
Ejemplo n.º 10
0
    public void ApplyDamage(int damage)
    {
        _currentHealth -= damage;

        if (_currentHealth <= 0)
        {
            _animator.Play("Die");
            PlayerDied?.Invoke();
        }
    }
Ejemplo n.º 11
0
    void Update()
    {
        Camera  camera   = Camera.main;
        Vector3 position = camera.ViewportToWorldPoint(new Vector3(0, 0, camera.nearClipPlane));

        if (transform.position.y < position.y)
        {
            PlayerDied?.Invoke();
        }
    }
Ejemplo n.º 12
0
 public GameEvents()
 {
     // Register a wrapper function to EntityDied which forwards player deaths to the more specific "PlayerDied"
     // (PlayerDied should never be directly invoked)
     EntityDied += (data) => {
         if (data.DeadEntity.Type == Entity.EntityType.Player)
         {
             PlayerDied?.Invoke(data);
         }
     };
 }
Ejemplo n.º 13
0
    /// <summary>
    /// Start is called before the first frame update
    /// </summary>
    void Start()
    {
        // Initialize fields
        rb2d           = GetComponent <Rigidbody2D>();
        radius         = GetComponent <CircleCollider2D>().radius;
        spriteRenderer = GetComponent <SpriteRenderer>();

        // Initialize event and add class as invoker
        playerDied = new PlayerDied();
        EventManager.AddPlayerDiedInvoker(this);
    }
Ejemplo n.º 14
0
        private void TakeDamageFrom(Player player)
        {
            VerifyIsNotDead();

            HitPoints -= player.AttackPower;

            if (IsDead)
            {
                PlayerDied?.Invoke(this);
            }
        }
Ejemplo n.º 15
0
        private void SendPlayerDiedPacket(PlayerDied e)
        {
            NetOutgoingMessage message = server.CreateMessage();

            new PlayerDiedPacket()
            {
                Player = e.who
            }.PacketToNetOutgoingMessage(message);

            server.SendToAll(message, NetDeliveryMethod.ReliableOrdered);
        }
Ejemplo n.º 16
0
    public void TakeDamage(int damage)
    {
        _audioSource.clip = _hurtSound;
        _audioSource.Play();
        _currentHealth -= damage;
        HealthChanged?.Invoke(_currentHealth, _health);

        if (_currentHealth <= 0)
        {
            PlayerDied?.Invoke();
            gameObject.SetActive(false);
        }
    }
Ejemplo n.º 17
0
    public void TakeDamage(int damage)
    {
        _animator.SetTrigger("TakeDamage");
        _audioSource.Play();

        _currentHealth -= damage;
        HealthChanged?.Invoke(_currentHealth, _health);

        if (_currentHealth <= 0)
        {
            gameObject.SetActive(false);
            PlayerDied?.Invoke();
        }
    }
Ejemplo n.º 18
0
    void Death()
    {
        // Set the death flag so this function won't be called again.
        isDead = true;

        // Turn off any remaining shooting effects.
        playerShooting.DisableEffects();

        // Turn off the movement and shooting scripts.
        playerMovement.enabled = false;
        playerShooting.enabled = false;

        if (PlayerDied != null)
        {
            PlayerDied.Invoke();
        }
    }
Ejemplo n.º 19
0
    public void TakeDamage(float damageAmount)
    {
        health -= damageAmount;
        health  = health > maxHealth ? maxHealth : health; // make sure health doesn't exceed max

        if (isPlayer)
        {
            PlayerTakeDamage.Invoke(health);
        }

        if (health <= 0)
        {
            if (isPlayer)
            {
                PlayerDied.Invoke();
            }
        }
    }
Ejemplo n.º 20
0
    void Start()
    {
        player      = GameObject.FindWithTag("Player");
        facingRight = true;

        soundManager        = FindObjectOfType <SoundManager>();
        levelTransition     = FindObjectOfType <LevelTransition>();
        levelCompleted      = FindObjectOfType <LevelCompleted>();
        gameCompleted       = FindObjectOfType <GameCompleted>();
        gameOver            = FindObjectOfType <GameOver>();
        playerDied          = FindObjectOfType <PlayerDied>();
        collectiblesManager = FindObjectOfType <CollectiblesManager>();
        lifeManager         = FindObjectOfType <LifeManager>();
        saveData            = FindObjectOfType <SaveData>();

        rigidBody = GetComponent <Rigidbody2D>();
        animator  = GetComponent <Animator>();
    }
Ejemplo n.º 21
0
    public void TakeDamage()
    {
        Debug.Log("Player " + playerNumber + " Taking damage!");

        hitAudioSource.Play();

        IsAlive = false;

        //disable player rigidbody and colliders
        //this way they fall over and off the map
        //also doesnt allow multiple damage to be taken
        playerRigidbody2D.constraints  = RigidbodyConstraints2D.None;
        playerBoxCollider2D.enabled    = false;
        playerCircleCollider2D.enabled = false;

        if (PlayerDied != null)
        {
            PlayerDied.Invoke(this);
        }
    }
Ejemplo n.º 22
0
        public static void FireEventsFromMessage(Message message)
        {
            switch (message.Id)
            {
            case Messages.IngameBotStart:
                IngameBotStart?.Invoke();
                return;

            case Messages.AreaChanged:
                AreaChanged?.Invoke(null, new AreaChangedArgs(message));
                return;

            case Messages.CombatAreaChanged:
                CombatAreaChanged?.Invoke(null, new AreaChangedArgs(message));
                return;

            case Messages.PlayerDied:
                PlayerDied?.Invoke(message.GetInput <int>());
                return;

            case Messages.PlayerResurrected:
                PlayerResurrected?.Invoke();
                return;

            case Messages.PlayerLeveled:
                PlayerLeveled?.Invoke(message.GetInput <int>());
                return;

            case Messages.ItemLootedEvent:
                ItemLootedEvent?.Invoke(message.GetInput <CachedItem>());
                return;

            case Messages.ItemStashedEvent:
                ItemStashedEvent?.Invoke(message.GetInput <CachedItem>());
                return;

            case Messages.ItemsSoldEvent:
                ItemsSoldEvent?.Invoke(null, new ItemsSoldArgs(message));
                return;
            }
        }
Ejemplo n.º 23
0
 public void PlayerDeath()
 {
     PlayerDied?.Invoke();
     Destroy(gameObject);
 }
Ejemplo n.º 24
0
 //BROADCASTER METHODS
 //Call to broadcast event
 public static void NotifyPlayerDied()
 {
     PlayerDied?.Invoke();
 }
Ejemplo n.º 25
0
 protected virtual void OnPlayerDied() => PlayerDied?.Invoke(this, EventArgs.Empty);
 private void OnPlayerDied(PlayerDied e)
 {
     _timeStamp = Time.unscaledTime;
     _isActive  = true;
 }
Ejemplo n.º 27
0
 private void Die()
 {
     PlayerDied?.Invoke();
 }
Ejemplo n.º 28
0
 private void OnPlayerDied(PlayerDied evt)
 {
     stateMachine.TransitionTo <GameOver>();
 }
Ejemplo n.º 29
0
    // Use this for initialization
    void Start()
    {
        //maxRayDistance = 20;
        anim = gameObject.GetComponent <Animator>();
        particleHolder.SetActive(false);

        agent = gameObject.GetComponentInParent <NavMeshAgent>();
        if (!agent)
        {
            agent = gameObject.transform.parent.root.GetComponent <NavMeshAgent>();
        }
        if (!agent)
        {
            agent = gameObject.transform.parent.root.GetComponentInChildren <NavMeshAgent>();
        }
        growlIndex = Random.Range(0, growls.Length);


        currentgrowl = growls[growlIndex];

        growlscript = GameObject.FindGameObjectWithTag("GrowlManager").GetComponent <GrowlManager>();

        levelMultiplier = LevelProgression.MasterLevelMultiplier;
        if (levelMultiplier == 0)
        {
            levelMultiplier = 1;
        }
        enemyStrength = 5 * levelMultiplier;
        if (attackDistance == 0)
        {
            attackDistance = 4;
        }
        soundhashInd = Random.Range(0, growls.Length);
        polypRB      = gameObject.GetComponent <Rigidbody>();



        character   = GetComponent <ThirdPersonCharacter>();
        clipPlaying = false;

        m_playerdied = GameObject.Find("DeathManager").GetComponent <PlayerDied>();
        if (!randomize)
        {
            waypointInd = 0;
        }

        if (randomize)
        {
            waypoints   = GameObject.FindGameObjectsWithTag("BossNavPoints");
            waypointInd = Random.Range(0, waypoints.Length);
        }

        Music = GameObject.Find("Music").GetComponent <AudioSource>();

        rolloffmode1 = AudioRolloffMode.Linear;
        //patrolSpeed = .5f;
        agent.updatePosition = true;
        agent.updateRotation = true;

        state = State.PATROL;

        alive = true;

        sound = gameObject.GetComponent <AudioSource>();



        sound.clip = chaseclip;
        //growlscript.StartCoroutine("GrowlsManager");
        StartCoroutine("FSM");
        multiplier = LevelProgression.MasterLevelMultiplier;
    }
Ejemplo n.º 30
0
 public void CallPlayerDied(GameObject go)
 {
     PlayerDied?.Invoke(go);
 }