void Attackable.BeAttack(Animal enemy) { if (enemy.Color.Equals(this.Color)) { return; } int hurt = enemy.Power; hurt = (int)(hurt * ReduceHurtRate); this.hp.Add(-hurt); //(ADD) if (GlobalAsset.player != null && this.position.IsOnPlain(GlobalAsset.player.Plain)) { Vector3 world_Point = Camera.main.WorldToScreenPoint(new Vector2(position.X.value, position.Y.value)); if (world_Point.x > 0 && world_Point.y > 0 && world_Point.x < Screen.width && world_Point.y < Screen.height) { damage_Text_Controller.Creat_Animator(world_Point, hurt); } } if (this.hp.IsZero) { // 收頭變強. Destroy(); enemy.Strong(10, 1, 1); } }
// return null : 創造失敗,能量不夠、格子不存在、格子已經有東西了. // return Animal : 創造的生物. private Animal CreateAnimalAt(Point3D position) { if (energy.Value < ReserveEnergy) { return(null); } Grid grid = World.GetAt(position); if (grid == null) { return(null); } var animal = new Animal(position, this); if (grid.InsertObj(animal)) { energy.Add(-costOfAnimal); // 生成器等級越高,生物越強. int extra = costOfAnimal / 10 * Level; energy.Add(-extra); animal.Strong(Level * 10, Level, Level); SkillManager.showSkill(Skill.create, position); GlobalAsset.animals.Add((Animal)grid.Obj); return((Animal)grid.Obj); } return(null); }
void Attackable.BeAttack(Animal enemy) { if (enemy.Color.Equals(this.Color)) { return; } int hurt = enemy.Power; hurt = (int)(hurt * ReduceHurtRate); this.hp.Add(-hurt); RegisterEvent(ObjEvent.damage); //(ADD) if (GlobalAsset.player != null && this.position.IsOnPlain(GlobalAsset.player.Plain)) { Damage_Text(hurt); } if (this.hp.IsZero) { // 收頭變強. Destroy(); enemy.Strong(10, 1, 1); } }
// 指定 animal 給玩家操作. private void AssignPlayer(Maze.Animal animal) { Player = animal; // for test 主角強化. Player.Strong(200, 10, 10); playerHintVector.SetActive(true); }