Esempio n. 1
0
    //单独放特效
    public void OnInflictHitEx(MoveAnimationEvent ee)
    {
        HitEventInfo            event_info    = ee.EventRef as MoveEditor.HitEventInfo;
        ParticleEventProperties particle_info = event_info._particleProperties;

        SpawnParitcle(particle_info, false, 0);
    }
Esempio n. 2
0
    private void EnemyHit(BaseEventInfo e)
    {
        HitEventInfo eventInfo = e as HitEventInfo;

        if (eventInfo != null && !eventInfo.ObjectHit.CompareTag("Player"))
        {
            GameObject playerThatShot = eventInfo.ObjectThatFired;
            GameObject hitObject      = eventInfo.ObjectHit;
            hitObject.SetActive(false);
            if (!playerScore.ContainsKey(playerThatShot))
            {
                playerScore.Add(playerThatShot, 1);
            }
            else
            {
                playerScore[playerThatShot]++;
                if (playerScore[playerThatShot] == winCondition)
                {
                    EliminateEventInfo winnerEvent = new EliminateEventInfo(playerThatShot);
                    EventHandler.Instance.FireEvent(EventHandler.EventType.FinaleWinEvent, winnerEvent);
                }
            }
            UpdatePlayerScoreEventInfo updateEventInfo = new UpdatePlayerScoreEventInfo()
            {
                Player = playerThatShot, Score = playerScore[playerThatShot]
            };
            EventHandler.Instance.FireEvent(EventHandler.EventType.UpdateScoreEvent, updateEventInfo);
        }
    }
Esempio n. 3
0
    //private void OnFire()
    //{
    //    if (IsOffCooldown && isActive)
    //    {
    //        var ray = Camera.main.ScreenPointToRay(Camera.main.WorldToScreenPoint(transform.position));
    //        if (Physics.Raycast(ray.origin, ray.direction, out var hit))
    //        {
    //            var direction = hit.point - transform.position;
    //            var rotation = Quaternion.Lerp(transform.rotation,Quaternion.LookRotation(direction),1);
    //            var obj = Instantiate(projectilePrefab, transform.position, rotation);
    //            obj.GetComponent<ProjectileMove>().PlayerThatShot = gameObject;
    //        }
    //        Cooldown.Instance.StartNewCooldown(cooldownDuration, this);
    //        IsOffCooldown = false;
    //    }
    //}

    private void OnFire()
    {
        if (IsOffCooldown && isActive)
        {
            var ray = Camera.main.ScreenPointToRay(Camera.main.WorldToScreenPoint(transform.position));
            if (Physics.Raycast(ray.origin, ray.direction, out var hit))
            {
                if (hit.collider.CompareTag("Enemy"))
                {
                    var e = new HitEventInfo(gameObject, hit.collider.gameObject);
                    EventHandler.Instance.FireEvent(EventHandler.EventType.HitEvent, e);
                }
                if (hitEffect != null)
                {
                    var hitClone = Instantiate(hitEffect, hit.point, Quaternion.identity);
                    var psHit    = hitClone.GetComponent <ParticleSystem>();
                    if (psHit != null)
                    {
                        Destroy(hitClone, psHit.main.duration);
                    }
                    else
                    {
                        var psChild = hitClone.transform.GetChild(0).GetComponent <ParticleSystem>();
                        Destroy(hitClone, psChild.main.duration);
                    }
                }
            }
            Cooldown.Instance.StartNewCooldown(cooldownDuration, this);
            IsOffCooldown = false;
        }
    }
Esempio n. 4
0
    void OnCollisionEnter(Collision collision)
    {
        speed = 0;
        ContactPoint contact = collision.contacts[0];

        if (collision.gameObject.CompareTag("Player") || collision.gameObject.CompareTag("Enemy"))
        {
            var e = new HitEventInfo(PlayerThatShot, collision.gameObject);
            EventHandler.Instance.FireEvent(EventHandler.EventType.HitEvent, e);
        }
        Quaternion rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
        Vector3    position = contact.point;

        if (hitPrefab != null)
        {
            var hitClone = Instantiate(hitPrefab, position, rotation);
            var psHit    = hitClone.GetComponent <ParticleSystem>();
            if (psHit != null)
            {
                Destroy(hitClone, psHit.main.duration);
            }
            else
            {
                var psChild = hitClone.transform.GetChild(0).GetComponent <ParticleSystem>();
                Destroy(hitClone, psChild.main.duration);
            }
        }
        Destroy(gameObject);
    }
Esempio n. 5
0
    public void OnInflictAudioEx(MoveAnimationEvent ee)
    {
        HitEventInfo         event_info = ee.EventRef as MoveEditor.HitEventInfo;
        AudioEventProperties audio_info = event_info._audioProperties;
        SpawnAudioClass      arg        = new SpawnAudioClass();

        arg.audio_info = audio_info;
        arg.startTime  = 0;

        SpawnAudio(arg.audio_info, false, arg.startTime);
    }
Esempio n. 6
0
    public void OnInflictHit(MoveAnimationEvent ee)
    {
        HitEventInfo event_info = ee.EventRef as MoveEditor.HitEventInfo;
        //PlayHitReactionProperties reaction_info = event_info._hitRxnProps;
        ParticleEventProperties particle_info = event_info._particleProperties;
        AudioEventProperties    audio_info    = event_info._audioProperties;

        if (particle_info._cancelIfMissed)
        {
        }
        SpawnHit(particle_info, audio_info, 0);
    }
Esempio n. 7
0
 private void CheckCollision()
 {
     Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, projectileRange, targetMask);
     if (hit.collider != null)
     {
         if (EventHandler.Instance != null)
         {
             var e = new HitEventInfo(gameObject, hit.collider.gameObject);
             EventHandler.Instance.FireEvent(EventHandler.EventType.HitEvent, e);
         }
     }
     ApplySelfKnockback();
 }
Esempio n. 8
0
        protected virtual void OnTakeDamage(HitEventInfo info)
        {
            // do take damage things
            // change to the take damage state
            float   detectionValue = _hostileHiddenStartingDetection;
            AIState nextState      = _onTakeDamageHostileHidden;

            // if the target is visible
            if (_npcTargetManager.TargetWithinRange(info.Attacker) && _npcTargetManager.TargetVisible(info.Attacker))
            {
                detectionValue = 1f + NPCTargetManager.AttentionBuffer;
                nextState      = _onTakeDamageHostileFound;
            }
            _npcTargetManager.RegisterOrUpdateHostile(info.Attacker, detectionValue);
            FireReadyToChangeState(nextState);
        }
Esempio n. 9
0
 private void CheckCollision()
 {
     Physics.Raycast(owner.transform.position, owner.transform.forward, out RaycastHit hit, projectileRange, targetMask);
     if (hit.collider != null)
     {
         if (EventHandler.Instance != null && hit.collider.gameObject.CompareTag("Player"))
         {
             var e = new HitEventInfo(owner.gameObject, hit.collider.gameObject);
             EventHandler.Instance.FireEvent(EventHandler.EventType.HitEvent, e);
         }
         else if (EventHandler.Instance != null && hit.collider.gameObject.CompareTag("Enemy"))
         {
             var e = new HitEventInfo(owner.gameObject, hit.collider.gameObject);
             EventHandler.Instance.FireEvent(EventHandler.EventType.HitEvent, e);
         }
     }
     ApplySelfKnockback();
     //TODO Migrate to KnockbackState instead
 }
Esempio n. 10
0
    private void EnemyHit(BaseEventInfo e)
    {
        HitEventInfo eventInfo      = e as HitEventInfo;
        GameObject   playerThatShot = eventInfo.ObjectThatFired;
        GameObject   hitObject      = eventInfo.ObjectHit;

        if (hitObject.GetComponent <PinataBehaviour>() != null)
        {
            HandlePinataHitEvent(hitObject, playerThatShot);
        }
        else if (hitObject.GetComponent <MovingTarget>() != null)
        {
            HandleChickenShootingGalleryHitEvent(hitObject, playerThatShot);
        }
        if (eventInfo != null && !eventInfo.ObjectHit.CompareTag("Player"))
        {
            if (gameIsActive)
            {
                int pts = 1;
                if (hitObject.GetComponent <PinataBehaviour>() != null)
                {
                    pts = hitObject.GetComponent <PinataBehaviour>().Points;
                }
                else if (hitObject.GetComponent <MovingTarget>() != null)
                {
                    pts = hitObject.GetComponent <MovingTarget>().Points;
                }
                AssignPoints(playerThatShot, pts);
                Player p      = GameController.Instance.FindPlayerByGameObject(playerThatShot);
                var    points = new Dictionary <Player, int>();
                points.Add(p, pts);
                MinigameController.Instance.MinigamePointSystem.UpdateScore(points);
                UpdatePlayerScoreEventInfo updateEventInfo = new UpdatePlayerScoreEventInfo()
                {
                    Player = playerThatShot, Score = playerScore[playerThatShot]
                };
                EventHandler.Instance.FireEvent(EventHandler.EventType.UpdateScoreEvent, updateEventInfo);
            }
            Destroy(hitObject);
        }
    }
Esempio n. 11
0
        public void Init(float startTime, HitEventInfo info, GameObject previewObject, GameObject hitObject, bool flipped)
        {
            if (hitObject == null)
            {
                return;
            }

            _hitEventInfo           = info;
            _previewCharacterObject = previewObject;
            _filpped   = flipped;
            _hitObject = hitObject;
            _hitMono   = _previewCharacterObject.GetComponent <HitMono>();
            if (_hitMono == null)
            {
                _hitMono = _previewCharacterObject.AddComponent <HitMono>();
            }

            _hitMono.EditorAwake();


            if (hitObject == null)
            {
                EB.Debug.LogError("Dont find previewHitObject");
                return;
            }

            _hitMono.targets    = new Transform[1];
            _hitMono.targets[0] = hitObject.transform;

            _hitObjectMono = hitObject.GetComponent <HitMono>();
            if (_hitObjectMono == null)
            {
                _hitObjectMono = hitObject.AddComponent <HitMono>();
            }

            _hitObjectMono.EditorAwake();
            _hitMono.SpawnHit(_hitEventInfo._particleProperties, _hitEventInfo._audioProperties, startTime);
        }
Esempio n. 12
0
    private void EliminatePinata(BaseEventInfo e)
    {
        HitEventInfo hitEventInfo = e as HitEventInfo;

        if (hitEventInfo != null)
        {
            GameObject playerThatShot = hitEventInfo.ObjectThatFired;
            GameObject objectHit      = hitEventInfo.ObjectHit;
            if (playerPinatas[playerThatShot].Contains(objectHit))
            {
                HandlePinataHitEvent(objectHit, playerThatShot);
                objectHit.SetActive(false);
                if (playerPinatas[playerThatShot].Count > 1)
                {
                    playerPinatas[playerThatShot].Remove(objectHit);
                }
                else
                {
                    OpenGate(playerThatShot);
                }
            }
        }
    }
Esempio n. 13
0
 protected virtual void OnTakeDamage(HitEventInfo info)
 {
     // do take damage things
 }