private void MakeCache() { if (dirtyDataId != dataId) { dirtyDataId = dataId; cacheSkill = null; cachePetItem = null; cachePrefab = null; switch (type) { case SummonType.Skill: if (GameInstance.Skills.TryGetValue(dataId, out cacheSkill)) { cachePrefab = cacheSkill.summon.monsterEntity; } break; case SummonType.Pet: if (GameInstance.Items.TryGetValue(dataId, out cachePetItem)) { cachePrefab = cachePetItem.petEntity; } break; } } }
protected override bool IsMonsterAlly(BaseMonsterCharacterEntity monsterCharacter, EntityInfo targetEntity) { if (string.IsNullOrEmpty(targetEntity.Id)) { return(false); } if (monsterCharacter is GuildWarMonsterCharacterEntity) { if (targetEntity.Type == EntityTypes.Player) { return(BaseGameNetworkManager.Singleton.DefenderGuildId != 0 && BaseGameNetworkManager.Singleton.DefenderGuildId == targetEntity.GuildId); } if (targetEntity.Type == EntityTypes.Monster) { // If this character is summoner so it is ally if (targetEntity.HasSummoner) { // If summoned by someone, will have same allies with summoner return(monsterCharacter.IsAlly(targetEntity.Summoner)); } else { // Monster always not player's ally return(false); } } return(true); } if (monsterCharacter.IsSummoned) { // If summoned by someone, will have same allies with summoner return(targetEntity.Id.Equals(monsterCharacter.Summoner.Id) || monsterCharacter.Summoner.IsAlly(targetEntity)); } if (targetEntity.Type == EntityTypes.GuildWarMonster) { // Monsters won't attack castle heart return(true); } if (targetEntity.Type == EntityTypes.Monster) { // If another monster has same allyId so it is ally if (targetEntity.HasSummoner) { return(monsterCharacter.IsAlly(targetEntity.Summoner)); } return(GameInstance.MonsterCharacters[targetEntity.DataId].AllyId == monsterCharacter.CharacterDatabase.AllyId); } return(false); }
public void Summon(BaseCharacterEntity summoner, short summonLevel, float duration) { if (GetPrefab() == null) { return; } var identity = BaseGameNetworkManager.Singleton.Assets.NetworkSpawn(GetPrefab().Identity, summoner.GetSummonPosition(), summoner.GetSummonRotation()); cacheEntity = identity.GetComponent <BaseMonsterCharacterEntity>(); CacheEntity.Summon(summoner, type, summonLevel); objectId = CacheEntity.ObjectId; summonRemainsDuration = duration; }
protected override bool IsMonsterEnemy(BaseMonsterCharacterEntity monsterCharacter, EntityInfo targetEntity) { if (string.IsNullOrEmpty(targetEntity.Id)) { return(false); } if (monsterCharacter is GuildWarMonsterCharacterEntity) { if (targetEntity.Type == EntityTypes.Player) { return(BaseGameNetworkManager.Singleton.DefenderGuildId == 0 || BaseGameNetworkManager.Singleton.DefenderGuildId != targetEntity.GuildId); } if (targetEntity.Type == EntityTypes.Monster) { // If this character is not summoner so it is enemy if (targetEntity.HasSummoner) { // If summoned by someone, will have same enemies with summoner return(monsterCharacter.IsEnemy(targetEntity.Summoner)); } else { // Monster always be player's enemy return(true); } } return(false); } if (monsterCharacter.IsSummoned) { // If summoned by someone, will have same enemies with summoner return(targetEntity.Id.Equals(monsterCharacter.Summoner.Id) && monsterCharacter.Summoner.IsEnemy(targetEntity)); } // Attack only player by default return(targetEntity.Type == EntityTypes.Player); }
protected override void SpawnInternal() { Vector3 spawnPosition = GetRandomPosition(); Quaternion spawnRotation = GetRandomRotation(); GameObject spawnObj = Instantiate(asset.gameObject, spawnPosition, spawnRotation); BaseMonsterCharacterEntity entity = spawnObj.GetComponent <BaseMonsterCharacterEntity>(); entity.gameObject.SetActive(false); // This is the change from GROUND_DETECTION_DISTANCE to squareGizmosHeight if (FindGroundedPosition(entity, spawnPosition, out spawnPosition)) { entity.Level = level; entity.SetSpawnArea(this, spawnPosition); BaseGameNetworkManager.Singleton.Assets.NetworkSpawn(spawnObj); } else { // Destroy the entity (because it can't find ground position) Destroy(entity.gameObject); ++pending; Logging.LogWarning(ToString(), "Cannot spawn monster, it cannot find grounded position, pending monster amount " + pending); } }
protected virtual bool FindGroundedPosition(BaseMonsterCharacterEntity entity, Vector3 spawnPosition, out Vector3 result) { return(entity.FindGroundedPosition(spawnPosition, squareGizmosHeight, out result)); }
public bool AddKillMonster(BaseMonsterCharacterEntity monsterEntity, int killCount) { return(AddKillMonster(monsterEntity.DataId, killCount)); }