public override void Init(CreateSceneCreature createNpc, CreatureDatabase npcDatabase) { base.Init(createNpc, npcDatabase); transform.position = createNpc.pos; //只对怪物启用 CheckAndInitAI(); }
public SpeciesStats(string species) { tcc = CreatureDatabase.GetCreatureCount(species); lcc = CreatureDatabase.GetLiveCreatureCount(species); List <Creature> live = CreatureDatabase.GetLive(species); ntr = new StatsDataPoint(live.Select(c => c.Nutrition).ToArray()); hyd = new StatsDataPoint(live.Select(c => c.Hydration).ToArray()); rpu = new StatsDataPoint(live.Select(c => c.ReproductiveUrge).ToArray()); hlt = new StatsDataPoint(live.Select(c => c.Health).ToArray()); }
public override void Init(CreateSceneCreature serverData, CreatureDatabase tableData) { base.Init(serverData, tableData); //主角设置一个单独的层 gameObject.layer = LayerMask.NameToLayer("MainRole"); BindingControlEvent(); _selectMgr.Init(this); _skillMgr.AutoSelectCallback += SelectCreature; }
public PeriodicDataPoint() { t = Time.time; fps = 1.0f / Time.deltaTime; tcc = CreatureDatabase.GetCreatureCount(); lcc = CreatureDatabase.GetLiveCreatureCount(); foreach (string species in CreatureDatabase.species.Keys) { ss.Add(species, new SpeciesStats(species)); } }
private void AddInitialEntities() { CreatureDatabase.Where( c => c.position_x > this.bounds.MinX && c.position_y > this.bounds.MinY && c.position_x < this.bounds.MaxX && c.position_y < this.bounds.MaxY).ToList().ForEach(this.AddCreatureEntity); GameObjectDatabase.Where( c => c.position_x > this.bounds.MinX && c.position_y > this.bounds.MinY && c.position_x < this.bounds.MaxX && c.position_y < this.bounds.MaxY).ToList().ForEach(this.AddGameObjectEntity); }
IEnumerator Gestate() { float miscarryChance = Random.Range(0.2f, 1f) * mother.genes[Genotype.Fertility]; for (;;) { if (Time.time > gestationStart + gestationPeriod) { StartCoroutine("Birth"); pregnant = false; yield break; } else if (0.01 > miscarryChance || CreatureDatabase.GetLiveCreatureCount() >= 2000) { Debug.Log(mother.ID + " miscarried (" + miscarryChance + "/" + CreatureDatabase.GetLiveCreatureCount() + ")."); StopCoroutine("Gestate"); pregnant = false; yield break; } yield return(null); } }
private void Awake() { transform.parent = GameObject.Find("Creatures").transform; originalScale = transform.localScale; navAgent = GetComponent <NavMeshAgent>(); gestation = GetComponent <GestationHandler>(); birthTime = Time.time; if (Generation == 1) { genes = GeneSet.GetFirstGenerationGenes(); birthTime = Time.time - 60f; maxNutrition = Mathf.Clamp(Mathf.Lerp(originalMaxNutrition - 2, originalMaxNutrition + 2, ability[Genotype.Nutrition]), 1, Mathf.Infinity); maxHydration = Mathf.Clamp(Mathf.Lerp(originalMaxHydration - 2, originalMaxHydration + 2, ability[Genotype.Nutrition]), 1, Mathf.Infinity); Nutrition = Random.Range(1f, maxNutrition); Hydration = Random.Range(1f, maxHydration); ReproductiveUrge = Random.Range(0.1f, 0.35f); } else { gender = (Random.Range(0, 2) == 1 ? GenderType.Male : GenderType.Female); } if (gestation != null && gender == GenderType.Male) { gestation.enabled = false; } ReproductiveUrge = 0f; CreatureDatabase.RegisterCreature(this); specieNo = (uint)CreatureDatabase.GetCreatureCount(this); name = ID; StartCoroutine(UpdateSight()); }
public virtual void Init(CreateSceneCreature serverData, CreatureDatabase tableData) { this.serverData = serverData; this.tableData = tableData; initMountPoint(); _agent = gameObject.AddComponent <NavMeshAgent>(); _agent.stoppingDistance = GameSetting.StopDistance; _agent.speed = 10f; //角速度 _agent.angularSpeed = float.MaxValue; //加速度 _agent.acceleration = float.MaxValue; //阻挡等级为不阻挡 _agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance; _rig = this.gameObject.AddComponent <Rigidbody>(); _rig.useGravity = false; _rig.isKinematic = true; _animator = gameObject.GetComponent <Animator>(); _skillMgr.Init(this); }
public override void Init(CreateSceneCreature serverData, CreatureDatabase tableData) { base.Init(serverData, tableData); _serverData = serverData as CreateSceneRole; _tableData = tableData as RoleDatabase; }