void Start() { transform.gameObject.tag = selfType.ToString(); aiWeapon = GetComponent <AIWeapon>(); initRotation = transform.rotation; MaxHp = HP; //dieParticle = DataManager.GetInstance().CreateGameObjectFromAssetsBundle("enemy", "explosion_stylized_large_jokerFire"); }
public AISharedContext() { AIMapHelper = new AIMapHelper(); AIMovement = new AIMovement(); AIWeapon = new AIWeapon(); AIItemDetection = new AIItemDetection(); AIInformation = new AIInformation(); }
void Start() { ConfigEnemy("Drone", 1, true, 5, 7, 10, 25, 5, 5, 5, 5); //enemySightRangeCollider = GetComponent<CircleCollider2D> (); //enemySightRangeCollider.radius = newRadius; weapon = new AIWeapon(this.gameObject); weapon.setPerm(this.damage, this.range, this.weaponVelocity, this.fireRate); this.sightLine = 20; }
void Start() { m_randomOffset = Random.value; m_weapon = GetComponentInChildren <AIWeapon>(); m_anim = GetComponent <Animator>(); m_stats = GetComponent <AIStats>(); m_player = Manager.GetPlayer().transform; m_randomInterval = Random.value; }
void SyncAIWeapon(int ID) { WeaponID = ID; Weapon = m_AIWeapons[ID]; foreach (AIWeapon item in m_AIWeapons) { item.WeaponObject.SetActive(false); } bullets = Weapon.Bullets; Weapon.WeaponObject.SetActive(true); Anim.SetInteger("GunType", (int)Weapon.Info.Type); }
private void SetupWeapon() { if (weapon == null) { weapon = gameObject.GetComponent <AIWeapon>(); } if (weapon == null) { print("still null"); } }
void Update() { foot.GetComponent <Animator>().SetFloat("Speed", GetComponent <Rigidbody2D>().velocity.magnitude); UpdatePosition(); if (AIMove != null) { AIMove.Update(); } if (AIWeapon != null) { AIWeapon.Update(); } }
void CreateEnemy() { Vector3 pos = new Vector3(); pos.x = UnityEngine.Random.value * 100; pos.y = UnityEngine.Random.value * -100; GameObject enemy = vc.CreateEnemy(pos); PlayerController ep = enemy.GetComponent <PlayerController>(); ep.HP = 100; ep.OnHitEvent += OnEnemyHit; ep.GetComponent <AgeCalculator>().DeadAge = Mathf.FloorToInt(UnityEngine.Random.value * 1000) + 500; ep.GetComponent <AgeCalculator>().OnDeadEvent += OnEnemySpeakEvent; ep.gameObject.name = "enemy"; AIMove moveAi = new AIMove(); moveAi.PlayerController = ep; moveAi.ViewController = vc; ep.AIMove = moveAi; WongWeaponController wwc = enemy.GetComponent <WongWeaponController>(); wwc.AimViewController = vc.AimViewController; wwc.AddWeapon(new object[] { "步槍(半自動)", 10, .6f, false, 5, 30.0f, 0.5f, false, 0.0f, false, false, 5, false, true }); /* * float wid = UnityEngine.Random.value; * if( wid < .6f) * { * wwc.AddWeapon(GameConfig.WeaponConfig[1]); * } * else if( wid < .8f) * { * wwc.AddWeapon(GameConfig.WeaponConfig[5]); * } * else * { * wwc.AddWeapon(GameConfig.WeaponConfig[0]); * } */ AIWeapon weaponAI = new AIWeapon(); weaponAI.PlayerController = ep; weaponAI.WongWeaponController = wwc; weaponAI.ViewController = vc; ep.AIWeapon = weaponAI; }
public void Initialize(Character character) { _parentCharacter = character; WorkingMemory = new WorkingMemory(); WorkingMemory.Initialize(_parentCharacter); BlackBoard = new BlackBoard(); Sensor = new AISensor(); Sensor.Initialize(_parentCharacter); TargetingSystem = new AITargeting(); TargetingSystem.Initialize(_parentCharacter); WeaponSystem = new AIWeapon(); WeaponSystem.Initialize(_parentCharacter); Planner = new GoapPlanner(this); _goals = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterGoalSet(_parentCharacter.GoapID); _actions = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterActionSet(_parentCharacter.GoapID); _currentWorldStates = new List <GoapWorldState>(); _parentCharacter.MyEventHandler.OnCurrentActionComplete -= OnCurrentActionComplete; _parentCharacter.MyEventHandler.OnCurrentActionComplete += OnCurrentActionComplete; _parentCharacter.MyEventHandler.OnPerFrameTimer -= PerFrameUpdate; _parentCharacter.MyEventHandler.OnPerFrameTimer += PerFrameUpdate; //update parent character for each action foreach (GoapAction action in _actions) { action.ParentCharacter = _parentCharacter; } //BlackBoard.PatrolLoc = new Vector3(63.9f, 0.3f, -13.3f); //BlackBoard.PatrolRange = new Vector3(30, 10, 15); if (ControlType != AIControlType.Player) { BlackBoard.GuardLevel = 1; _parentCharacter.SendCommand(CharacterCommands.SetAlert); } _currentGoal = null; _currentAction = null; _parentCharacter.MyEventHandler.OnOneSecondTimer += OnOneSecondTimer; }
public void Initialize(Character character) { _parentCharacter = character; WorkingMemory = new WorkingMemory(); WorkingMemory.Initialize(_parentCharacter); BlackBoard = new BlackBoard(); Sensor = new AISensor(); Sensor.Initialize(_parentCharacter); TargetingSystem = new AITargeting(); TargetingSystem.Initialize(_parentCharacter); WeaponSystem = new AIWeapon(); WeaponSystem.Initialize(_parentCharacter); Planner = new GoapPlanner(this); _goals = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterGoalSet(_parentCharacter.GoapID); _actions = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterActionSet(_parentCharacter.GoapID); _currentWorldStates = new List<GoapWorldState>(); _parentCharacter.MyEventHandler.OnCurrentActionComplete += OnCurrentActionComplete; _parentCharacter.MyEventHandler.OnPerFrameTimer += PerFrameUpdate; //update parent character for each action foreach(GoapAction action in _actions) { action.ParentCharacter = _parentCharacter; } //BlackBoard.PatrolLoc = new Vector3(63.9f, 0.3f, -13.3f); //BlackBoard.PatrolRange = new Vector3(30, 10, 15); if(ControlType != AIControlType.Player) { BlackBoard.GuardLevel = 1; _parentCharacter.SendCommand(CharacterCommands.SetAlert); } _currentGoal = null; _currentAction = null; _parentCharacter.MyEventHandler.OnOneSecondTimer += OnOneSecondTimer; }
public void InitAIBaseByEnity(Enity enity) { this.enity = enity; selfType = enity.enityType; attackType = EnityManager.GetInstance().GetAttackEnityType(selfType); isCanMove = enity.enityType == EnityType.Hero; searchRadius = DataManager.instance.GetConfigValueToFloat("fight_search_radius"); moveSpeed = DataManager.instance.GetConfigValueToFloat("fight_move_speed"); moveAnimatorType = AnimatorAction.Run; animator = enity.gameObject.GetComponent <Animator>(); //////////////////////////判断是否装备武器/////////////////////////////////// Item equip = enity.GetEnityEquip(); if (equip != null) { aiWeapon = gameObject.AddComponent <AIWeapon>(); aiWeapon.InitWeaponByEquip(equip); } isInit = true; }
public void Initialize(Character character) { _parentCharacter = character; WorkingMemory = new WorkingMemory(); WorkingMemory.Initialize(_parentCharacter); BlackBoard = new BlackBoard(); Sensor = new AISensor(); Sensor.Initialize(_parentCharacter); TargetingSystem = new AITargeting(); TargetingSystem.Initialize(_parentCharacter); WeaponSystem = new AIWeapon(); WeaponSystem.Initialize(_parentCharacter); Planner = new GoapPlanner(this); _goals = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterGoalSet(_parentCharacter.ID); _actions = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterActionSet(_parentCharacter.ID); _currentWorldStates = new List<GoapWorldState>(); _parentCharacter.MyEventHandler.OnNewEnemyTargetFound += OnImportantEvent; _parentCharacter.MyEventHandler.OnCurrentActionComplete += OnCurrentActionComplete; //update parent character for each action foreach(GoapAction action in _actions) { action.ParentCharacter = _parentCharacter; } BlackBoard.PatrolLoc = new Vector3(-15, 0, -15); BlackBoard.PatrolRange = new Vector3(20, 10, 20); BlackBoard.HasPatrolInfo = true; if(ControlType != AIControlType.Player) { _currentGoal = null; _currentAction = null; FindAndExecuteAction(); } }
private void SetupWeapon() { if(weapon == null) { weapon = gameObject.GetComponent<AIWeapon>(); } if(weapon == null) { print ("still null"); } }