/// <summary> /// Luo komponentit, alustaa ne ja antaa ne argumenttina saadulle /// peliobjektille. /// </summary> /// <param name="monster">Peliobjekti jolle komponentit lisätään.</param> private void CreateComponents(GameObject monster) { TargetingComponent targetingComponent = new TargetingComponent(monster, new string[] { "monster", "world" }) { RangeX = 32f, RangeY = 32f }; HealthComponent healthComponent = new HealthComponent(monster, statSet); rotation.Disable(); FacingComponent facing = new FacingComponent(monster); SteeringComponent steeringComponent = new SteeringComponent(monster); DamageRenderer r = new DamageRenderer(monster); r.Initialize(); r.Color = Color.Red; monster.AddComponent(r); monster.AddComponent(statSet); monster.AddComponent(targetingComponent); monster.AddComponent(healthComponent); monster.AddComponent(skillSet); monster.AddComponent(rotation); monster.AddComponent(facing); monster.AddComponent(steeringComponent); monster.AddComponent(weaponComponent); monster.InitializeComponents(); }
public void AddToGameWorld(GameWorldController gameWorldController) { m_pathfindingComponent = new PathfindingComponent(this); m_steeringComponent = new SteeringComponent(this); m_characterWidget = gameWorldController.View.AddCharacterWidget(m_characterData); gameWorldController.Model.AddCharacterEntity(this); }
public void RemoveFromGameWorld(GameWorldController gameWorldController) { gameWorldController.Model.RemoveCharacterEntity(this); gameWorldController.View.RemoveCharacterWidget(m_characterWidget); m_characterWidget = null; m_pathfindingComponent = null; m_steeringComponent = null; }
public CharacterEntity(int characterId) { SessionData sessionData = SessionData.GetInstance(); m_characterId = characterId; m_characterData = sessionData.CurrentGameData.GetCharacterById(m_characterId); m_position = new Point3d(m_characterData.x, m_characterData.y, m_characterData.z); m_facing = MathConstants.GetUnitVectorForAngle(m_characterData.angle); m_characterWidget = null; m_pathfindingComponent = null; m_steeringComponent = null; }
public MobEntity(int characterId) { SessionData sessionData = SessionData.GetInstance(); m_mobId = characterId; m_mobData = sessionData.CurrentGameData.CurrentRoom.GetMobById(m_mobId); m_position = new Point3d(m_mobData.x, m_mobData.y, m_mobData.z); m_facing = MathConstants.GetUnitVectorForAngle(m_mobData.angle); m_dialogTimer = -1.0f; m_mobWidget = null; m_pathfindingComponent = null; m_steeringComponent = null; }
protected override void OnInitialize() { MonsterBuilder builder = new BlobBuilder(); builder.Build(Owner); Tree tree = CreateTree(); tree.Initialize(); Owner.AddComponent(tree); spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\Boss\Boss"); spriterComponent.Initialize(); spriterComponent.ChangeAnimation("Walk"); spriterComponent.Scale = 0.75f; Owner.AddComponent(spriterComponent); steeringComponent = Owner.FirstComponentOfType <SteeringComponent>(); SteeringBehavior seek = new SeekBehavior() { DesiredVelocity = new Vector2(1.25f), MaxSpeed = 1.25f }; steeringComponent.AddBehavior(seek); steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior)); rotation = Owner.FirstComponentOfType <SkillRotation>(); targetingComponent = Owner.FirstComponentOfType <TargetingComponent>(); BossHealthComponent c = new BossHealthComponent(Owner); c.Initialize(); Owner.AddComponent(c); rotation.Enable(); }
// TODO: duplicated code. Crawlerilla melkein sama init logic. protected override void OnInitialize() { MonsterBuilder builder = new ZombieBuilder(); builder.Build(Owner); Tree tree = CreateTree(); tree.Initialize(); Owner.AddComponent(tree); // Idle, Walk, Attack spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\GenericZombie\GenericZombie"); spriterComponent.Initialize(); spriterComponent.ChangeAnimation("Walk"); spriterComponent.Scale = 0.5f; Owner.AddComponent(spriterComponent); steeringComponent = Owner.FirstComponentOfType <SteeringComponent>(); SteeringBehavior flee = new FleeBehavior() { DesiredVelocity = new Vector2(4.25f), MaxSpeed = 3.25f }; SteeringBehavior seek = new SeekBehavior() { DesiredVelocity = new Vector2(4.25f), MaxSpeed = 3.25f }; steeringComponent.AddBehavior(flee); steeringComponent.AddBehavior(seek); steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior)); }
protected override void OnInitialize() { MonsterBuilder builder = new CrawlerBuilder(); builder.Build(Owner); Tree tree = CreateTree(); tree.Initialize(); Owner.AddComponent(tree); spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\Crawler\crawler"); spriterComponent.Initialize(); spriterComponent.ChangeAnimation("NewAnimation"); spriterComponent.Scale = 0.3f; Owner.AddComponent(spriterComponent); steeringComponent = Owner.FirstComponentOfType <SteeringComponent>(); SteeringBehavior flee = new FleeBehavior() { DesiredVelocity = new Vector2(2.25f), MaxSpeed = 1.25f }; SteeringBehavior seek = new SeekBehavior() { DesiredVelocity = new Vector2(2.25f), MaxSpeed = 1.25f }; steeringComponent.AddBehavior(flee); steeringComponent.AddBehavior(seek); steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior)); }
public void RemoveFromGameWorld(GameWorldController gameWorldController) { gameWorldController.Model.RemoveMobEntity(this); gameWorldController.View.RemoveMobWidget(m_mobWidget); m_mobWidget = null; m_pathfindingComponent = null; m_steeringComponent = null; }
public void AddToGameWorld(GameWorldController gameWorldController) { m_pathfindingComponent = new PathfindingComponent(this); m_steeringComponent = new SteeringComponent(this); m_mobWidget = gameWorldController.View.AddMobWidget(m_mobData); gameWorldController.Model.AddMobEntity(this); }
// Use this for initialization void Start() { steering = gameObject.GetComponent <SteeringComponent>(); rigid = gameObject.GetComponent <Rigidbody2D>(); }
void OnEnable() { _targetObject = (SteeringComponent)serializedObject.targetObject; }