Example #1
0
    private void NPCFallAction(GameObject obj, NPCComponent behavior)
    {
        _audioSrc.clip = fallSounds.GetRandom();
        _audioSrc.Play();

        GameHelper.GameManager.OnGameOver -= GameOverAction;
    }
Example #2
0
    void Start()
    {
        heroAnimator            = this.GetComponent <Animator>();
        heroCharacterController = this.GetComponent <CharacterController>();
        sphereColliderComponent = transform.Find("SphereCollider").GetComponent <SphereColliderComponent>();

        sphereColliderComponent.OnTriggerEnterEvent += (collider) => {
            if (collider.transform.tag == "NPC")
            {
                attackNPC = collider.transform.GetComponent <NPCComponent>();
            }
            if (collider.transform.tag == "Player" && collider.gameObject.name != playerUnitData.PlayerId.ToString())
            {
                attackPlayer = collider.transform.GetComponent <PlayerComponent>();
            }
        };
        sphereColliderComponent.OnTriggerExitEvent += (collider) => {
            if (collider.transform.tag == "NPC")
            {
                attackNPC = null;
            }
            if (collider.transform.tag == "Player" && collider.gameObject.name != playerUnitData.PlayerId.ToString())
            {
                attackPlayer = null;
            }
        };


        SyncPlayerData.Instance.syncPositionBack += SyncPositionBack;
    }
Example #3
0
 public void Setup(NPCComponent npcComp)
 {
     associatedComponent = npcComp;
     if (associatedComponent != null)
     {
         buttonText.text = associatedComponent.GetType().ToString();
     }
 }
Example #4
0
 public static void addEvent(NPCComponent component, float time)
 {
     if (inSession)
     {
         componentList.Add(component);
         timeList.Add(time);
     }
 }
Example #5
0
    private void OnTriggerExit2D(Collider2D other)
    {
        NPCComponent npc = other.GetComponent <NPCComponent>();

        if (npc == null)
        {
            return;
        }

        _closeNPCs.Remove(npc);
    }
Example #6
0
    /// <summary>
    /// 攻击
    /// </summary>
    public void Attack(NPCComponent npc, PlayerComponent player)
    {
        player.hPComponent.AddAttackHp(200);
        float curHp = player.hPComponent.GetCurHp();

        channel01.Send <CSHurtInfo>(new CSHurtInfo()
        {
            AttackerId  = npc.nPCId,
            HurterId    = player.playerUnitData.PlayerId,
            HurterCurHp = curHp
        });
    }
Example #7
0
    // Start is called before the first frame update
    private void Start()
    {
        _npc      = GetComponent <NPCComponent>();
        _audioSrc = GetComponent <AudioSource>();
        _data     = GetComponent <NPCDataComponent>();

        _currentTime = minTime;
        _targetTime  = 0;

        _npc.OnFall += NPCFallAction;
        GameHelper.GameManager.OnGameOver += GameOverAction;
    }
Example #8
0
    /// <summary>
    /// 增加血条
    /// </summary>
    /// <returns></returns>
    public HPComponent AddNPCHPUI(NPCComponent npc)
    {
        Transform obj = Instantiate(HPUIPrefab);

        obj.localScale = Vector3.one;
        obj.gameObject.transform.SetParent(transform.Find("HP"));
        HPComponent hp = obj.GetComponent <HPComponent>();

        hp.followObj = npc.transform;
        hp.Init();

        return(hp);
    }
        private void OnMobStateChange(EntityUid uid, NPCComponent component, MobStateChangedEvent args)
        {
            switch (args.CurrentMobState)
            {
            case DamageState.Alive:
                WakeNPC(component);
                break;

            case DamageState.Critical:
            case DamageState.Dead:
                SleepNPC(component);
                break;
            }
        }
    public void Init()
    {
        playerComponent = followObj.GetComponent <PlayerComponent>();
        npcComponent    = followObj.GetComponent <NPCComponent>();

        isHero = playerComponent != null ? true : false;
        maxHp  = isHero ? 600f : 200f;

        SyncPlayerData.Instance.HurtInfoBack   += HurtInfoEvent;
        SyncPlayerData.Instance.PlayerInfoBack += PlayerInfo;

        slider             = this.GetComponent <Slider>();
        slider.maxValue    = maxHp / 200f;
        slider.value       = maxHp / 200f;
        transform.position = Camera.main.WorldToScreenPoint(this.followObj.position) + new Vector3(0, 190f, 0);
    }
 private void OnDetectiveRemarkEnd(Clue clue)
 {
     if (currentRoom.sceneName == "kevin_lighting")
     {
         foreach (var npc in npcsInRoom)
         {
             NPCComponent npcData = npc.GetComponent <NPCComponent>();
             if (npcData.requiredClue != null)
             {
                 if (clue == npcData.requiredClue)
                 {
                     npc.SetActive(true);
                 }
             }
         }
     }
 }
Example #12
0
    public void DeadNPC(NPCComponent npc)
    {
        npc.SetEnable(false);

        if (npc.attackHero.GetComponent <PlayerComponent>().playerUnitData.PlayerId == PlayerManager.Instance.GetHeroPlayer().playerUnitData.PlayerId)
        {
            ItemData.Instance.killNum++;
            ItemData.Instance.grade += 50;

            GGame.GameEntry.Event.Fire(this, new BattleUIEventArgs());
        }

        GGame.GameEntry.Cooldown.AddTimer(npc.GetHashCode(), 15f, () => {
            npc.SetEnable(true);

            GGame.GameEntry.Cooldown.RemoveTimer(npc.GetHashCode());
        }).Start();
    }
    private void CheckForNpcDisabling(GameObject npc)
    {
        RoomItem internalNpc = currentRoom.roomItemsList.Find(item => item._name == npc.name);

        npc.SetActive(internalNpc.isEnabled);
        NPCComponent npcData = npc.GetComponent <NPCComponent>();

        if (npcData.enteringPhase != null && npcData.leavingPhase != null)
        {
            Debug.Log(PhaseManager.currentPhase.phaseIndex);
            if (PhaseManager.currentPhase.phaseIndex >= npcData.enteringPhase.phaseIndex)
            {
                npc.SetActive(true);
                internalNpc.isEnabled = true;
                //EditorUtility.SetDirty(currentRoom);
                if (PhaseManager.currentPhase.phaseIndex >= npcData.leavingPhase.phaseIndex)
                {
                    npc.SetActive(false);
                    internalNpc.isEnabled = false;
                    //EditorUtility.SetDirty(currentRoom);
                }
            }
        }
    }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory = new AggregateFactory(this);
            WeaponFactory = new WeaponFactory(this);
            DoorFactory = new DoorFactory(this);
            RoomFactory = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory = new WallFactory(this);
            EnemyFactory = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory = new NPCFactory(this);

            // Initialize Components
            PlayerComponent = new PlayerComponent();
            LocalComponent = new LocalComponent();
            RemoteComponent = new RemoteComponent();
            PositionComponent = new PositionComponent();
            MovementComponent = new MovementComponent();
            MovementSpriteComponent = new MovementSpriteComponent();
            SpriteComponent = new SpriteComponent();
            DoorComponent = new DoorComponent();
            RoomComponent = new RoomComponent();
            HUDSpriteComponent = new HUDSpriteComponent();
            HUDComponent = new HUDComponent();
            InventoryComponent = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent = new EquipmentComponent();
            WeaponComponent = new WeaponComponent();
            BulletComponent = new BulletComponent();
            PlayerInfoComponent = new PlayerInfoComponent();
            WeaponSpriteComponent = new WeaponSpriteComponent();
            StatsComponent = new StatsComponent();
            EnemyAIComponent = new EnemyAIComponent();
            NpcAIComponent = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent = new CollisionComponent();
            TriggerComponent = new TriggerComponent();
            EnemyComponent = new EnemyComponent();
            NPCComponent = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent = new SoundComponent();
            ActorTextComponent = new ActorTextComponent();
            TurretComponent = new TurretComponent();
            TrapComponent = new TrapComponent();
            ExplodingDroidComponent = new ExplodingDroidComponent();
            HealingStationComponent = new HealingStationComponent();
            PortableShieldComponent = new PortableShieldComponent();
            PortableStoreComponent = new PortableStoreComponent();
            ActiveSkillComponent = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();

            Quests = new List<Quest>();

            #region Initialize Effect Components
            AgroDropComponent = new AgroDropComponent();
            AgroGainComponent = new AgroGainComponent();
            BuffComponent = new BuffComponent();
            ChanceToSucceedComponent = new ChanceToSucceedComponent();
            ChangeVisibilityComponent = new ChangeVisibilityComponent();
            CoolDownComponent = new CoolDownComponent();
            DamageOverTimeComponent = new DamageOverTimeComponent();
            DirectDamageComponent = new DirectDamageComponent();
            DirectHealComponent = new DirectHealComponent();
            FearComponent = new FearComponent();
            HealOverTimeComponent = new HealOverTimeComponent();
            InstantEffectComponent = new InstantEffectComponent();
            KnockBackComponent = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent = new ReduceAgroRangeComponent();
            ResurrectComponent = new ResurrectComponent();
            StunComponent = new StunComponent();
            TimedEffectComponent = new TimedEffectComponent();
            EnslaveComponent = new EnslaveComponent();
            CloakComponent = new CloakComponent();
            #endregion

            base.Initialize();
        }
Example #15
0
    /// <summary>
    /// 增加血条
    /// </summary>
    /// <returns></returns>
    public HPComponent AddNPCHPUI(NPCComponent npc)
    {
        var hp = battleUIForm.AddNPCHPUI(npc);

        return(hp);
    }
 private void OnNPCInit(EntityUid uid, NPCComponent component, ComponentInit args)
 {
     WakeNPC(component);
 }
 private void OnNPCShutdown(EntityUid uid, NPCComponent component, ComponentShutdown args)
 {
     SleepNPC(component);
 }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AggregateFactory   = new AggregateFactory(this);
            WeaponFactory      = new WeaponFactory(this);
            DoorFactory        = new DoorFactory(this);
            RoomFactory        = new RoomFactory(this);
            CollectableFactory = new CollectibleFactory(this);
            WallFactory        = new WallFactory(this);
            EnemyFactory       = new EnemyFactory(this);
            SkillEntityFactory = new SkillEntityFactory(this);
            NPCFactory         = new NPCFactory(this);

            // Initialize Components
            PlayerComponent          = new PlayerComponent();
            LocalComponent           = new LocalComponent();
            RemoteComponent          = new RemoteComponent();
            PositionComponent        = new PositionComponent();
            MovementComponent        = new MovementComponent();
            MovementSpriteComponent  = new MovementSpriteComponent();
            SpriteComponent          = new SpriteComponent();
            DoorComponent            = new DoorComponent();
            RoomComponent            = new RoomComponent();
            HUDSpriteComponent       = new HUDSpriteComponent();
            HUDComponent             = new HUDComponent();
            InventoryComponent       = new InventoryComponent();
            InventorySpriteComponent = new InventorySpriteComponent();
            ContinueNewGameScreen    = new ContinueNewGameScreen(graphics, this);
            EquipmentComponent       = new EquipmentComponent();
            WeaponComponent          = new WeaponComponent();
            BulletComponent          = new BulletComponent();
            PlayerInfoComponent      = new PlayerInfoComponent();
            WeaponSpriteComponent    = new WeaponSpriteComponent();
            StatsComponent           = new StatsComponent();
            EnemyAIComponent         = new EnemyAIComponent();
            NpcAIComponent           = new NpcAIComponent();

            CollectibleComponent = new CollectibleComponent();
            CollisionComponent   = new CollisionComponent();
            TriggerComponent     = new TriggerComponent();
            EnemyComponent       = new EnemyComponent();
            NPCComponent         = new NPCComponent();
            //QuestComponent = new QuestComponent();
            LevelManager             = new LevelManager(this);
            SpriteAnimationComponent = new SpriteAnimationComponent();
            SkillProjectileComponent = new SkillProjectileComponent();
            SkillAoEComponent        = new SkillAoEComponent();
            SkillDeployableComponent = new SkillDeployableComponent();
            SoundComponent           = new SoundComponent();
            ActorTextComponent       = new ActorTextComponent();
            TurretComponent          = new TurretComponent();
            TrapComponent            = new TrapComponent();
            ExplodingDroidComponent  = new ExplodingDroidComponent();
            HealingStationComponent  = new HealingStationComponent();
            PortableShieldComponent  = new PortableShieldComponent();
            PortableStoreComponent   = new PortableStoreComponent();
            ActiveSkillComponent     = new ActiveSkillComponent();
            PlayerSkillInfoComponent = new PlayerSkillInfoComponent();
            MatchingPuzzleComponent  = new MatchingPuzzleComponent();
            pI = new PlayerInfo();

            Quests = new List <Quest>();


            #region Initialize Effect Components
            AgroDropComponent          = new AgroDropComponent();
            AgroGainComponent          = new AgroGainComponent();
            BuffComponent              = new BuffComponent();
            ChanceToSucceedComponent   = new ChanceToSucceedComponent();
            ChangeVisibilityComponent  = new ChangeVisibilityComponent();
            CoolDownComponent          = new CoolDownComponent();
            DamageOverTimeComponent    = new DamageOverTimeComponent();
            DirectDamageComponent      = new DirectDamageComponent();
            DirectHealComponent        = new DirectHealComponent();
            FearComponent              = new FearComponent();
            HealOverTimeComponent      = new HealOverTimeComponent();
            PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent();
            InstantEffectComponent     = new InstantEffectComponent();
            KnockBackComponent         = new KnockBackComponent();
            TargetedKnockBackComponent = new TargetedKnockBackComponent();
            ReduceAgroRangeComponent   = new ReduceAgroRangeComponent();
            ResurrectComponent         = new ResurrectComponent();
            StunComponent              = new StunComponent();
            TimedEffectComponent       = new TimedEffectComponent();
            EnslaveComponent           = new EnslaveComponent();
            CloakComponent             = new CloakComponent();
            #endregion

            base.Initialize();
        }
 /// <summary>
 /// Is the NPC awake and updating?
 /// </summary>
 public bool IsAwake(NPCComponent component, ActiveNPCComponent?active = null)
 {
     return(Resolve(component.Owner, ref active, false));
 }
Example #20
0
 public static void RemoveEvent(NPCComponent component)
 {
     componentList.Remove(component);
 }
 /// <summary>
 /// Allows the NPC to actively be updated.
 /// </summary>
 public void WakeNPC(NPCComponent component)
 {
     _sawmill.Debug($"Waking {ToPrettyString(component.Owner)}");
     EnsureComp <ActiveNPCComponent>(component.Owner);
 }
    private void TriggerRandomSentence(NPCComponent npcData)
    {
        Clue randomRemark = npcData.NoDialogueRemarks[GetRandomInt(npcData.NoDialogueRemarks.Length)];

        OnDetectiveRemarkStarted(randomRemark);
    }
 /// <summary>
 /// Stops the NPC from actively being updated.
 /// </summary>
 public void SleepNPC(NPCComponent component)
 {
     _sawmill.Debug($"Sleeping {ToPrettyString(component.Owner)}");
     RemComp <ActiveNPCComponent>(component.Owner);
 }