public MapObject CreateZombieToMap(string resPath, Vector3 logicPos) { // 逻辑 MapObject mapObject = MapObjectMgr.InstanceMapObject(); MapObjectAttribute mapObjectAttribute = mapObject.GetAttribute <MapObjectAttribute>(); Vector3 postion = new Vector3(logicPos.x * GameDefine.Art.GardenCellSize.x, logicPos.y * GameDefine.Art.GardenCellSize.y, 0); mapObjectAttribute.Position = postion; mapObjectAttribute.Hp = 5; // 表现 GameObject gameObject = PopPool(resPath, true); if (gameObject == null) { gameObject = GlobalEnvironment.Instance.Get <ResourceManager>().Instance(resPath); gameObject.transform.SetParent(MapObjctParent.transform); } MapObjectResPathDict.Add(mapObjectAttribute.Id, resPath); MapObjectArtAttribute mapObjectArtAttribute = mapObject.GetAttribute <MapObjectArtAttribute>(); mapObjectArtAttribute.gameObject = gameObject; mapObjectArtAttribute.transform = gameObject.transform; mapObjectArtAttribute.transform.position = postion; mapObjectArtAttribute.MaxSpeed = 0.001f; RepresentMgr.RegisterMapObject <MoveArtHandle>(mapObject); RepresentMgr.RegisterMapObject <DeathArtHandle>(mapObject); DailyMgr.RegisterDailyAction(mapObject, new TriggerZombieMoveDailyAction()); AllMapObjectList.Add(mapObject); return(mapObject); }
public override void Execute(MapObject mapObject) { MapObjectAttribute attribute = mapObject.GetAttribute <MapObjectAttribute>(); MapObjectArtAttribute art = mapObject.GetAttribute <MapObjectArtAttribute>(); if (attribute == null || art == null) { return; } if (attribute.Hp > 0) { return; } int layer = art.gameObject.layer; Vector3 position = art.transform.position; GlobalEnvironment.Instance.Get <GameMapObjectManager>().DestroyMapObject(mapObject); BattleGameScene battleGameScene = (BattleGameScene)GlobalEnvironment.Instance.Get <SceneManager>().GetScene(GameDefine.Scene.Battle); GardenBattleGamePlay gardenBattleGamePlay = (GardenBattleGamePlay)battleGameScene.GamePlay; gardenBattleGamePlay.CharacterDeath(layer, position); }
public override void Execute() { Node.Complete = true; if (Zombie != null) { MapObjectAttribute bulletAttribute = Info.mapObject.GetAttribute <MapObjectAttribute>(); if (bulletAttribute.Hp != 0) { MapObjectAttribute mapOjectAttribute = Zombie.GetAttribute <MapObjectAttribute>(); mapOjectAttribute.Hp -= Info.Attack; bulletAttribute.Hp = 0; } AttachAttackAttribute attachAttackBuff = Info.mapObject.GetAttribute <AttachAttackAttribute>(); if (attachAttackBuff != null) { if (attachAttackBuff.Fire > 0) { GlobalEnvironment.Instance.Get <BuffManager>().AddBuff(Zombie, new AttachAttackBuff()); } } } }
public override void Execute(MapObject mapObject) { MapObjectAttribute attribute = mapObject.GetAttribute <MapObjectAttribute>(); MapObjectArtAttribute art = mapObject.GetAttribute <MapObjectArtAttribute>(); if (attribute == null || art == null) { return; } if (art.transform == null) { return; } if (art.MaxSpeed == 0) { Debug.LogError("MaxSpeed Is 0. mapObject Name:" + art.transform.name); } Vector3 transformPos = art.transform.position; Vector3 distance = attribute.Position - transformPos; if (distance.x > art.MaxSpeed || distance.x < -art.MaxSpeed) { distance.x = art.MaxSpeed * (distance.x > 0 ? 1 : -1); } if (distance.y > art.MaxSpeed && distance.y < -art.MaxSpeed) { distance.y = art.MaxSpeed * (distance.y > 0 ? 1 : -1); } art.transform.position += distance; }
public override void Enter() { Info = (AttachAttackBehaviorInfo)Enviorment; if (Info.mapObject != null && Info.mapObject.IsActive()) { mapOjectAttribute = Info.mapObject.GetAttribute <MapObjectAttribute>(); attachAttackAttribute = Info.mapObject.GetAttribute <AttachAttackAttribute>(); } }
public override void Execute() { MapObjectAttribute mapOjectAttribute = Info.mapObject.GetAttribute <MapObjectAttribute>(); if (mapOjectAttribute.Hp <= 0) { return; } DailyManager dailyManager = GlobalEnvironment.Instance.Get <DailyManager>(); dailyManager.RegisterDailyAction(Info.mapObject, Info.dailyAction); }
public override void Execute() { if (Plant == null || Plant.IsActive() == false) { Node.Complete = true; } else { MapObjectAttribute mapOjectAttribute = Plant.GetAttribute <MapObjectAttribute>(); mapOjectAttribute.Hp -= Info.Attack; if (mapOjectAttribute.Hp <= 0) { Node.Complete = true; } } }
public override BehaviorTree Create() { BehaviorTree behaviorTree = new BehaviorTree(); MapObjectAttribute mapOjectAttribute = mapObject.GetAttribute <MapObjectAttribute>(); IntervalBehavior intervalBehavior = new IntervalBehavior(10, -1); TouchZombieBehavior touchZombieBehavior = new TouchZombieBehavior(); TouchZombieBehavior.TouchZombieBehaviorInfo touchZombieInfo = new TouchZombieBehavior.TouchZombieBehaviorInfo(); touchZombieInfo.dir = Vector3.right; touchZombieInfo.distance = GameDefine.Art.GardenCellSize.x * (GameDefine.Garden.GardenWidth - mapOjectAttribute.Position.x + 0.5f); touchZombieInfo.mapObject = mapObject; touchZombieBehavior.Enviorment = touchZombieInfo; intervalBehavior.AddBehavior(touchZombieBehavior); behaviorTree.AddBehavior("TouchZombie", intervalBehavior, BehaviorTree.NodeType.Serial); SingleNodeBehavior singleNodeBehavior = new SingleNodeBehavior(); UseSkillBehavior useSkillBehavior = new UseSkillBehavior(); UseSkillBehavior.UseSkillBehaviorInfo useSkillBehaviorInfo = new UseSkillBehavior.UseSkillBehaviorInfo(); useSkillBehaviorInfo.mapObject = mapObject; useSkillBehaviorInfo.skill = new FireBulletSkill(); useSkillBehavior.Enviorment = useSkillBehaviorInfo; singleNodeBehavior.AddBehavior(useSkillBehavior); AddDailyActionBehavior addDailyActionBehavior = new AddDailyActionBehavior(); AddDailyActionBehavior.AddDailyActionBehaviorInfo addDailyActionBehaviorInfo = new AddDailyActionBehavior.AddDailyActionBehaviorInfo(); addDailyActionBehaviorInfo.mapObject = mapObject; addDailyActionBehaviorInfo.dailyAction = new TriggerShooterDailyAction(); addDailyActionBehavior.Enviorment = addDailyActionBehaviorInfo; singleNodeBehavior.AddBehavior(addDailyActionBehavior); behaviorTree.AddBehavior("skill", singleNodeBehavior, BehaviorTree.NodeType.Serial); return(behaviorTree); }
public MapObject CreatePlantToMap(string resPath, Vector3 logicPos) { if (!GardenMap.IsCanCreateMapObjectToMap(logicPos)) { return(null); } // 逻辑 MapObject mapObject = MapObjectMgr.InstanceMapObject(); GardenMap.AddMapObjectToMap(mapObject.GetAttribute <MapObjectAttribute>().Id, logicPos); MapObjectAttribute mapObjectAttribute = mapObject.GetAttribute <MapObjectAttribute>(); mapObjectAttribute.Position = logicPos; mapObjectAttribute.Hp = 5; // 表现 GameObject gameObject = PopPool(resPath, true); if (gameObject == null) { gameObject = GlobalEnvironment.Instance.Get <ResourceManager>().Instance(resPath); gameObject.transform.SetParent(MapObjctParent.transform); } MapObjectResPathDict.Add(mapObjectAttribute.Id, resPath); MapObjectArtAttribute mapObjectArtAttribute = mapObject.GetAttribute <MapObjectArtAttribute>(); mapObjectArtAttribute.gameObject = gameObject; mapObjectArtAttribute.transform = gameObject.transform; Vector3 postion = new Vector3(logicPos.x * GameDefine.Art.GardenCellSize.x, logicPos.y * GameDefine.Art.GardenCellSize.y, 0); mapObjectArtAttribute.transform.position = postion; RepresentMgr.RegisterMapObject <DeathArtHandle>(mapObject); AllMapObjectList.Add(mapObject); return(mapObject); }
public override void Execute() { Debug.DrawLine(follow.position, follow.position + Info.dir * Info.distance, Color.red); if (Physics.Raycast(follow.position, Info.dir, out hitInfo, Info.distance, layerMask)) { // Debug.Log("Touch Plant!"); Node.Complete = true; Transform touch = hitInfo.collider.transform; MapObject plant = GlobalEnvironment.Instance.Get <MapObjectManager>().GetMapObject(touch); if (plant != null) { TouchPlantBehaviorEnvironmentInfo environmentInfo = new TouchPlantBehaviorEnvironmentInfo(); environmentInfo.Plant = plant; Node.BehaviorTree.Environment.Add <TouchPlantBehaviorEnvironmentInfo>(environmentInfo); MapObjectAttribute mapOjectAttribute = Info.mapObject.GetAttribute <MapObjectAttribute>(); mapOjectAttribute.Position = follow.position; } } }
public MapObject CreateBullet(Vector3 position) { string resPath = GameDefine.Path.Bullet; MapObject mapObject = GlobalEnvironment.Instance.Get <MapObjectManager>().InstanceMapObject(); MapObjectAttribute mapObjectAttribute = mapObject.GetAttribute <MapObjectAttribute>(); mapObjectAttribute.Hp = 1; mapObjectAttribute.Position = position; MapObjectArtAttribute mapObjectArtAttribute = mapObject.GetAttribute <MapObjectArtAttribute>(); GameObject gameObject = PopPool(resPath, false); if (gameObject == null) { gameObject = GlobalEnvironment.Instance.Get <ResourceManager>().Instance(resPath); gameObject.transform.SetParent(MapObjctParent.transform); } MapObjectResPathDict.Add(mapObjectAttribute.Id, resPath); mapObjectArtAttribute.gameObject = gameObject; mapObjectArtAttribute.transform = gameObject.transform; mapObjectArtAttribute.transform.position = position; mapObjectArtAttribute.MaxSpeed = 0.002f; mapObject.AddAttribute <AttachAttackAttribute>(typeof(AttachAttackAttribute).Name, new AttachAttackAttribute()); GlobalEnvironment.Instance.Get <DailyManager>().RegisterDailyAction(mapObject, new BulletMoveDailyAction()); GlobalEnvironment.Instance.Get <RepresentManager>().RegisterMapObject <MoveArtHandle>(mapObject); GlobalEnvironment.Instance.Get <RepresentManager>().RegisterMapObject <DeathArtHandle>(mapObject); GlobalEnvironment.Instance.Get <RepresentManager>().RegisterMapObject <AttachArtHandle>(mapObject); AllMapObjectList.Add(mapObject); return(mapObject); }