Exemple #1
0
    private void Start()
    {
        myMaster = GetComponent <Character>();

        idle       = new CharacterIdle(myMaster, this);
        locomotion = new CharacterLocomotion(myMaster, this);
        jump       = new CharacterJump(myMaster, this);
        fall       = new CharacterFall(myMaster, this);
        climb      = new CharacterClimb(myMaster, this);
        crouch     = new CharacterCrouch(myMaster, this);
        zapped     = new CharacterZapped(myMaster, this);
        turn       = new CharacterTurn(myMaster, this);
        interact   = new CharacterInteract(myMaster, this);
        death      = new CharacterDeath(myMaster, this);
        dialogue   = new CharacterDialogue(myMaster, this);
        disabled   = new CharacterDisabled(myMaster, this);
        train      = new CharacterEventTrain(myMaster, this);

        currentState = idle;

        //Special event niveau 1
        if (!GameManager.instance.spcLvlMan.hasHead)
        {
            ChangeState(train);
        }
    }
Exemple #2
0
        public static void OnCharacterDeath(ICharacter deadCharacter)
        {
            var publicState = deadCharacter.GetPublicState <ICharacterPublicState>();

            if (!publicState.IsDead)
            {
                publicState.CurrentStats.ServerSetHealthCurrent(0);
                return;
            }

            // recreate physics (as dead character doesn't have any physics)
            deadCharacter.ProtoCharacter.SharedCreatePhysics(deadCharacter);

            if (deadCharacter.ProtoCharacter is IProtoCharacterMob protoCharacterMob)
            {
                Api.SafeInvoke(() => CharacterDeath?.Invoke(deadCharacter));
                protoCharacterMob.ServerOnDeath(deadCharacter);
                return;
            }

            // player character death
            // remember the death position (useful for the respawn)
            var privateState = PlayerCharacter.GetPrivateState(deadCharacter);

            privateState.LastDeathPosition = deadCharacter.TilePosition;
            privateState.LastDeathTime     = Api.Server.Game.FrameTime;
            ServerTimersSystem.AddAction(
                delaySeconds: PlayerTeleportToGraveyardDelaySeconds,
                () =>
            {
                if (!publicState.IsDead)
                {
                    // player has already respawned
                    return;
                }

                CharacterDespawnSystem.ServerTeleportPlayerCharacterToServiceArea(deadCharacter);
                CharacterRespawnSystem.ServerRemoveStatusEffectsOnRespawn(deadCharacter);
            });

            var isPvPdeath = CharacterDamageTrackingSystem.ServerGetPvPdamagePercent(deadCharacter)
                             >= 0.5;

            // register death (required even if the player is not a newbie)
            NewbieProtectionSystem.ServerRegisterDeath(deadCharacter,
                                                       isPvPdeath,
                                                       out var shouldSufferDeathConsequences);

            if (shouldSufferDeathConsequences)
            {
                DropPlayerLoot(deadCharacter);
            }
            else
            {
                Api.Logger.Important("Player character is dead - newbie PvP case, no loot drop or other consequences",
                                     deadCharacter);
            }

            Api.SafeInvoke(() => CharacterDeath?.Invoke(deadCharacter));
        }
    private void CharacterDeath_Died(CharacterDeath source, CharacterDeadBody deadBody)
    {
        OneShotAudioEffect effect = OneShotAudioEffectPooler.Get();

        effect.Set(source.Transform.position);
        effect.gameObject.SetActive(true);
    }
Exemple #4
0
    private void CharacterDeath_Died(CharacterDeath source, CharacterDeadBody deadBody)
    {
        OneShotAudio audio = OneShotAudioPooler.Get();

        audio.Set(AudioClip, Transform.position);
        audio.gameObject.SetActive(true);
    }
 private void FixedUpdate()
 {
     if (hitTimer > 0f)
     {
         hitTimer -= Time.fixedDeltaTime;
     }
     else
     {
         if (toHit)
         {
             toHit = false;
             CharacterDeath.Kill(HitGetColliders);
         }
         if (Animator.CurrentSpriteAnimation == WhipAnimation)
         {
             if (Animator.IsFinished)
             {
                 SetValue(true);
             }
         }
         else if (WhipRequest)
         {
             AudioSource.Play();
             SetValue(false);
             Animator.SetAnimation(WhipAnimation);
             HitGetColliders.ShapeParameter.Offset.x = SpriteRenderer.flipX ? -HitOffsetX : HitOffsetX;
             hitTimer = HitTime;
             toHit    = true;
         }
     }
     WhipRequest = false;
 }
Exemple #6
0
    public override void Die(DieType type = DieType.explode)
    {
        isAlive = false;
        CharacterDeath death = new CharacterDeath {
        };

        EventAggregator.Publish(death);
    }
 private void BuddhaHeadAIDeath_Died(CharacterDeath source, CharacterDeadBody deadBody)
 {
     AIActionListComponent.ActionList.ClearActions();
     foreach (Spawn spawn in spawning)
     {
         spawn.gameObject.SetActive(false);
     }
     spawning.Clear();
     while (spawnedCharacters.Count > 0)
     {
         spawnedCharacters[0].Death.Die();
     }
     TreasureObj.SetActive(true);
 }
 // Use this for initialization
 void Awake()
 {
     _Health = MaxHealth;
     _healthbarManager = GameObject.Find("HealthbarCanvas");
     if (!_healthbarManager)
         CreateHealthBarManager ();
     _waveManager = GameObject.Find("WaveManager").GetComponent<WaveManager>();
     _scoreManager = GameObject.Find("ScoreManager").GetComponent<ScoreManager>();
     _pickupManager = GameObject.Find("PickupManager").GetComponent<PickupManager>();
     _DeathHandler = GetComponent<CharacterDeath> ();
     if (_DeathHandler == null) {
         Debug.LogWarning("<CharacterHealth[Awake]>: "+gameObject.name+" has no death handler, adding default");
         _DeathHandler=(CharacterDeath)gameObject.AddComponent<GenericDeath>();
     }
 }
 public bool Execute(AIActionList.Token token)
 {
     if (token.Source.SpriteRenderer.flipX)
     {
         AttackGetColliders.ShapeParameter.Offset.x = -AttackOffsetX;
     }
     else
     {
         AttackGetColliders.ShapeParameter.Offset.x = AttackOffsetX;
     }
     if (toAttack && !attackTimer.Execute(Time.fixedDeltaTime))
     {
         toAttack = false;
         CharacterDeath.Kill(AttackGetColliders);
     }
     return(true);
 }
 //Play a morbid death speel and end the game
 public static void death(string reason)
 {
     //Slow things down so the death speel is more creepy
     Character.Settings["SpeechSpeed"] = 2;
     CharacterDeath.Speel(reason);
     showCharInfoGUI();
     EOA.pressAnyKeyToContinue();
     if (CharacterDeath.lastCheckpoint())
     {
         CharacterDeath.resetStats();                 // reset character
         ast.start.Menu start = new ast.start.Menu(); //initialise new menu
         start.menuSeq();                             // restart
     }
     else
     {
         new ast.story().Run();
     }
 }
        public void Ray(Vector2 target)
        {
            if (!newAimTimer.Execute(Time.fixedDeltaTime))
            {
                newAimTimer.SetTime(NewAimTime);
                aimTime = Random.Range(MinAimTime, MaxAimTime);
            }

            Vector2 dir = target - (Vector2)Origin.position;

            Rest((Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg) + 90f);

            const float maxDistance = 1000f;

            LaserTransform.position = Origin.position;
            LaserTransform.rotation = Quaternion.Euler(0f, 0f, Angle);
            Vector2      raySize = new Vector2(0.375f, 0.5f);
            RaycastHit2D hit     = Physics2D.BoxCast(Origin.position, raySize, Angle, Direction, maxDistance, Action.ObstacleLayerMask);
            float        dis;

            if (hit.collider)
            {
                dis = hit.distance;
                LaserSpriteRenderer.size = new Vector2(1f, (dis * (1f / 0.625f)) + 0.5f);
            }
            else
            {
                dis = maxDistance;
                LaserSpriteRenderer.size = new Vector2(1f, dis);
            }
            LaserGameObject.SetActive(true);

            foreach (RaycastHit2D h in Physics2D.BoxCastAll(Origin.position, raySize, Angle, Direction, dis, Action.KillLayerMask))
            {
                OneShotAudioEffect effect = Action.LaserHitOneShotAudioEffectPooler.Get();
                effect.Set(h.transform.position);
                effect.gameObject.SetActive(true);
                CharacterDeath.Kill(h.collider);
            }
        }
 private void PlayerCharacterDeath_Died(CharacterDeath source, CharacterDeadBody deadBody)
 {
     AddDeath();
 }
 // Use this for initialization
 void Start()
 {
     player = GameObject.Find("Player");
     race = player.GetComponent<StartRace>();
     playerPhysics = player.GetComponent<PhysicsPlayerTester>();
     playerDeath = player.GetComponent<CharacterDeath>();
     score = player.GetComponent<TeamsScore>();
     fairy= GameObject.Find ("curseur");
     screenCursor = fairy.GetComponent<JoystickCursor> ();
     victory = GameObject.Find ("Victory").GetComponent<VictoryBlock>();
 }
 private void CharacterDeath_Died(CharacterDeath source, CharacterDeadBody deadBody)
 {
     PlayerStatistics.AddKill();
 }
 private void CharacterDeath_Died(CharacterDeath source, CharacterDeadBody deadBody)
 {
     Transform.position = pos;
     GameObject.SetActive(true);
 }