コード例 #1
0
    // Use this for initialization
    void Start()
    {
        data = (JsonObject)JsonValue.Parse (entityDef.ToString ());

        // consider making these joints
        foreach(JsonObject node in data["nodes"]) {
            GameObject obj = (GameObject)Object.Instantiate(nodeType,
                                                new Vector3(node["pos"][0], node["pos"][1], node["pos"][2]),
                                                new Quaternion());

            obj.transform.parent = transform;
            euids[node["euid"]] = new EntityComponent(node, obj);
        }

        // Yay add sprite data
        foreach (JsonObject bone in data["bones"]) {
            EntityComponent from = euids[bone["from"]];
            EntityComponent to = euids[bone["to"]];

            GameObject boneObject = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
            boneObject.transform.position = from.gameObject.transform.position;
            boneObject.transform.LookAt(to.gameObject.transform.position);
            boneObject.transform.localScale.Set(1, 1, Vector3.Distance(from.gameObject.transform.position, to.gameObject.transform.position));
            boneObject.transform.parent = transform;

            euids[bone["euid"]] = new EntityComponent(bone, boneObject);
        }
    }
コード例 #2
0
	public override void HandleOnTargetHit(ProjectileEntity source, EntityComponent target)
	{
		base.HandleOnTargetHit(source, target);
		
		target.Damage(Magnitude, MyEntityComponent);		
		target.BroadcastMessage("BeingAttacked", this.MyEntityComponent);
	}
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityComponentEventArgs"/> struct.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="componentKey">The component key.</param>
 /// <param name="previousComponent">The previous component.</param>
 /// <param name="newComponent">The new component.</param>
 public EntityComponentEventArgs(Entity entity, PropertyKey componentKey, EntityComponent previousComponent, EntityComponent newComponent)
 {
     Entity = entity;
     ComponentKey = componentKey;
     PreviousComponent = previousComponent;
     NewComponent = newComponent;
 }
コード例 #4
0
	protected void HandleBossDied(EntityComponent boss, EntityComponent lastAttacker)
	{
		boss.onEntityDeath -= HandleBossDied;
		
		if (OnBossDeath != null)
			OnBossDeath(boss, lastAttacker);		
	}
コード例 #5
0
    void HandleOnHeroDied(EntityComponent died, EntityComponent lastAttacker)
    {
		NumHeroesAlive--;
		
		if (onHeroDied != null)
			onHeroDied(died, lastAttacker);
    }
コード例 #6
0
	void HandleOnEntityDestroyed (EntityComponent entityComponent)
	{
		myEntity.onHealthChanged -= OnTargetHealthChanged;
		myEntity.onEntityDestroyed -= HandleOnEntityDestroyed;
		
		healthBarGUIManager.onToggleHealthBar -= HandleOnToggleHealthBar;
	}
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityComponentEventArgs"/> struct.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="componentKey">The component key.</param>
 /// <param name="previousComponent">The previous component.</param>
 /// <param name="newComponent">The new component.</param>
 public EntityComponentEventArgs(Entity entity, int index, EntityComponent previousComponent, EntityComponent newComponent)
 {
     Entity = entity;
     Index = index;
     PreviousComponent = previousComponent;
     NewComponent = newComponent;
 }
コード例 #8
0
	void HandleOnNoticedEntityEvent(EntityComponent noticed)
	{
		if (!unitsNoticed.Contains(noticed))
		{
			noticed.onEntityDeath += HandleOnEntityDeath;
			unitsNoticed.Add(noticed);	
		}
	}
コード例 #9
0
	protected override void OnStopTargeting (EntityComponent attacker, EntityComponent attackee)
	{
		//Let us start moving again normally.
		myEntityComponent.myMovement.ResumeMovement();
		myEntityComponent.myMovement.CurrTarget = null;
		
		base.OnStopTargeting (attacker, attackee);
	}
コード例 #10
0
	void HandleOnChargingActionEvent(EntityComponent attacker, EntityComponent target, float chargeTime)
	{
		if (chargingActionEffectScript != null)
		{
			chargingActionEffectScript.Target = target.transform;
			chargingActionEffectScript.Visible = true;
			chargingActionEffectScript.Play();
		}
	}
コード例 #11
0
	protected void HandleOnHeroDied(EntityComponent source, EntityComponent killer)
	{
		if (killer != null && killer is MonsterComponent)
		{
			int gold = EntityFactory.GetInstance().GetHeroInfo(source.DataName).gold;
			AddGold(gold);	
			goldGUIManager.FireGoldParticle(gold, source.transform.position);
		}
	}
コード例 #12
0
	public override bool Attach(EntityComponent targetEntity)
	{
		bool attached = base.Attach(targetEntity);
		
		if (attached)
			timeRemaining = totalEffectTime;
		
		return attached;
	}
コード例 #13
0
	public virtual void Detach()
	{
		if (target != null)
		{
			target.DetachModifier(this);
		}
		
		ResetEntity();		
		target = null;
	}
コード例 #14
0
	protected void OnHeroDeath(EntityComponent dead, EntityComponent lastAttacker)
	{
		if (dead is HeroComponent)
		{
			RemovePartyMember(dead as HeroComponent);
			dead.onEntityDeath -= OnHeroDeath;;
			
			if (OnHeroDied != null)
				OnHeroDied(dead, lastAttacker);
		}
	}
コード例 #15
0
	protected void OnAttackStateTransition(EntityComponent source, AttackManagerState state)
	{
		//If we're transitioning to idle then set our current target to the current waypoint
		if (state == AttackManagerState.Idle && CurrWaypoint != null)
		{
			CurrTarget = CurrWaypoint.transform;
			ForceRepath();
			performingActions = false;
		}		
		else if (state == AttackManagerState.Attacking)
		{
			performingActions = true;
		}
	}
コード例 #16
0
	void HandleOnWatchedHeroDeath(EntityComponent source, EntityComponent killer)
	{
		HeroComponent heroComp = source as HeroComponent;
		
		if (heroComp != null)
		{
			heroComp.onEntityDeath -= HandleOnWatchedHeroDeath;
			enemiesInRange.Remove(heroComp);
			
			if (enemyTracking == heroComp)
			{
				SetEnemy();
			}			
		}
	}
コード例 #17
0
	public virtual void HandleOnTargetHit(ProjectileEntity source, EntityComponent target)
	{
		//Apply our attack effects.
		if (target != null && target.Alive)
		{
			foreach (EntityModifier modifier in actionModifiers.Values)
			{
				modifier.DeepClone().Attach(target);
			}
		}		
		
		//Let any listeners know
		if (OnTargetHitEvent != null)
			OnTargetHitEvent(MyEntityComponent, MyActionManager.myBehaviorManager.CurrentTarget);
	}
コード例 #18
0
ファイル: Entity.cs プロジェクト: eweilow/Forgotten-Voxels
 public bool AddComponent(EntityComponent component)
 {
     if(!HasComponentOfType(component.GetType()))
     {
         if(component.AllDependenciesLinked())
         {
             component.entity = this;
             component.OnLink();
             components.Add(component);
             return true;
         }
         Console.WriteLine("Error! Not all dependencies were linked in type {0}", component.GetType());
         return false;
     }
     Console.WriteLine("Error! Already had component of type {0}", component.GetType());
     return false;
 }
コード例 #19
0
	public virtual bool Attach(EntityComponent targetEntity)
	{
		bool attached = false;
		
		if (targetEntity != null)
		{
			attached = targetEntity.AttachModifier(this);	
			
			if (attached)
			{
				this.target = targetEntity;
				ModifyEntity();
			}			
		}	
		
		return attached;
	}
コード例 #20
0
	public override void HandleOnTargetHit(ProjectileEntity source, EntityComponent target)
	{
		base.HandleOnTargetHit(source, target);
		
		Collider[] colliders = Physics.OverlapSphere(target.transform.position, Radius, layerMask);
		
		//Loop through all resulting colliders, seeing if we can snatch an EntityComponent from them that is of our target type
		//Then damage it if that is the case!
		foreach (Collider collider in colliders)
		{
			EntityComponent entity = collider.gameObject.GetComponent<EntityComponent>();
			
			if (entity != null && entity.GetType() == myTargetType)
			{
				entity.Damage(Magnitude, MyEntityComponent);		
				entity.BroadcastMessage("BeingAttacked", this.MyEntityComponent);				
			}			
		}		
	}
コード例 #21
0
	public virtual void FireAction(EntityComponent target)
	{
		OnPerformingAction(target);
		
		if (Projectile != null) //We're firing a projectile, wait for it before we apply the results of our action!
		{
			Vector3 offset = MyEntityComponent.attackPoint.position;
			offset.x += Projectile.GetComponent<ProjectileEntity>().FiringOffset.x * (MyEntityComponent.Facing == Facing.Left ? -1 : 1);
			offset.z += Projectile.GetComponent<ProjectileEntity>().FiringOffset.y;
			
			GameObject newProj = (GameObject) GameObject.Instantiate(Projectile, offset, Quaternion.identity);
			AnimatedProjectile projectileEntityScript = newProj.GetComponent<AnimatedProjectile>();
			projectileEntityScript.Target = target;
			projectileEntityScript.speed = Projectile.GetComponent<ProjectileEntity>().speed;
			
			//projectileEntityScript.animationName = Projectile.GetComponent<AnimatedProjectile>().animationName;
			
			projectileEntityScript.OnProjectileHitTargetEvent += HandleOnTargetHit;
		}
		else
			HandleOnTargetHit(null, target);
	}
コード例 #22
0
	protected override void HandleOnBehaviorStateChangedEvent(EntityComponent entity, BaseBehaviorStates newState)
	{
		//If we're performing actions at this point in time then mark that down so we don't change our Current Waypoint
		//And then let's stop moving!
		if (newState  == BaseBehaviorStates.PerformingActions) 
		{
			performingActions = true;
			StopMovement();
		}
		else if (newState == BaseBehaviorStates.Moving) //If we're moving then we have to find out if we need to grab a new target or not...
		{
			if (CurrTarget == null && CurrWaypoint != null) //We have no target, set our waypoint to our target
			{
				CurrTarget = CurrWaypoint.transform;				
			}
			
			ResumeMovement();
			ForceRepath();
			performingActions = false;
		}
		
		base.HandleOnBehaviorStateChangedEvent (entity, newState);
	}
コード例 #23
0
	void Start () 
	{
		if (entityComponent == null)
			entityComponent = transform.parent.parent.GetComponent<EntityComponent>();
		
		if (actionManager == null)
			actionManager = transform.parent.parent.FindChild("Attack").GetComponent<ActionManager>();
		
		if (mySprite == null)
			mySprite = this.GetComponent<tk2dAnimatedSprite>();
		
		//Attach ourselves to the relevant events
		entityComponent.onEntityDeath += HandleOnEntityDeath;
		entityComponent.onEntityDestroyed += HandleOnEntityDestroyed;
		
		if (actionManager != null)
		{
			actionManager.OnChargingActionEvent += HandleOnChargingActionEvent;
			actionManager.OnPerformingActionEvent += HandleOnActionEvent;
			actionManager.OnTargetHitEvent += HandleOnTargetHitEvent;
		}
		
		prevFacing = Facing.Right;
		playingIdleAnim = true;		
		playingWalkAnim = false;
		playingEventAnim = false;
		
		mySprite.animationCompleteDelegate = OnAnimationComplete;
		mySprite.animationEventDelegate = OnAnimationEvent;
				
		//When the Entity moves we want to play the movement animation
		//When the Entity does a pre/during/post attack we want to play the pre/during/post attack animation
		//We'll have to check every once in a while to see if the entity is moving or not in Update and change the animation accordingly
		//while also keeping track of the fact that we don't want to co-opt other animations currently playing.
	
	}	
コード例 #24
0
 public EntityComponentReference(EntityReference entity, PropertyKey component)
 {
     this.entity = entity;
     this.component = component;
     this.value = null;
 }
コード例 #25
0
ファイル: Json.cs プロジェクト: TheRatCircus/Pantheon-Unity
        private static void GenerateSampleTemplate()
        {
            Assets.LoadAssets();
            GameObject    mockGo           = new GameObject();
            GameObject    fxShrapnelPrefab = new GameObject("FX_Shrapnel");
            TurnScheduler scheduler        = mockGo.AddComponent <TurnScheduler>();

            Locator.Scheduler = scheduler;

            EntityComponent[] components = new EntityComponent[]
            {
                new Actor()
                {
                    Control = ActorControl.None
                },
                new AI(new ApproachUtility(), new AttackUtility(), new FleeUtility()),
                new Ammo()
                {
                    Type    = AmmoType.Cartridges,
                    Damages = new Damage[]
                    {
                        new Damage()
                        {
                            Type = DamageType.Piercing,
                            Min  = 3,
                            Max  = 7
                        }
                    },
                    OnLandCommand = new ExplodeCommand(null)
                    {
                        Prefab  = fxShrapnelPrefab,
                        Pattern = ExplosionPattern.Square,
                        Damages = new Damage[]
                        {
                            new Damage()
                            {
                                Type = DamageType.Searing,
                                Min  = 3,
                                Max  = 7
                            }
                        }
                    },
                },
                new Body(),
                new Corpse(),
                new Dialogue(),
                new Evocable(),
                new Health(),
                new Inventory(20),
                new Location(),
                new Melee(
                    new MeleeAttack(
                        new Damage[]
                {
                    new Damage()
                    {
                        Type = DamageType.Slashing,
                        Min  = 2,
                        Max  = 5
                    }
                }, 80, 120)),
                new OnDamageTaken(),
                new OnUse(TurnScheduler.TurnTime),
                new Relic()
                {
                    Name = "Orb of Zot"
                },
                new Size(1),
                new Species(null),
                new Splat()
                {
                    Sound = null
                },
                new Status(),
                new Talented()
                {
                    Talents = new Talent[]
                    {
                        new Talent()
                        {
                            ID = "Talent_Foobar"
                        },
                    }
                },
                new Weight(50),
                new Wield(2)
            };

            EntityTemplate template = new EntityTemplate
            {
                ID         = "SAMPLE_ID",
                EntityName = "SAMPLE_NAME",
                Flags      = EntityFlag.Unique | EntityFlag.Blocking,
                Components = components,
                Inventory  = new EntityTemplate[]
                {
                    new EntityTemplate
                    {
                        ID = "Item_SampleItem"
                    }
                },
                Wielded = new EntityTemplate[]
                {
                    new EntityTemplate
                    {
                        ID = "Item_SampleWeapon"
                    }
                }
            };

            string path = Application.dataPath + $"/Sample/sample_template.json";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                TypeNameHandling    = TypeNameHandling.Auto,
                SerializationBinder = Binders._entity,
                Formatting          = Formatting.Indented,
                Converters          = new List <JsonConverter>()
                {
                    new GameObjectConverter(),
                    new SpriteConverter(),
                    new TalentConverter(),
                    new TileConverter(),
                    new RuleTileConverter(),
                    new SpeciesDefinitionConverter(),
                    new BodyPartConverter(),
                    new StatusConverter()
                }
            };

            File.AppendAllText(path, JsonConvert.SerializeObject(template, settings));
            AssetDatabase.Refresh();
            Object.DestroyImmediate(mockGo as GameObject);
            Object.DestroyImmediate(fxShrapnelPrefab as GameObject);
            Debug.Log($"Wrote sample template with all components to {path}.");
            Assets.UnloadAssets();
        }
コード例 #26
0
 protected void OnComponentRemovedEvent(Entity entity, EntityComponent component)
 {
     UnwatchComponent(component);
     FireRefreshRequest(entity);
 }
コード例 #27
0
 public static void ShowThruster(this EntityComponent entityComponent, ThrusterData data)
 {
     entityComponent.ShowEntity(typeof(Thruster), "Thruster", data);
 }
コード例 #28
0
 public static int GenerateSerialId(this EntityComponent entityComponent)
 {
     return(--s_SerialId);
 }
コード例 #29
0
ファイル: BackgroundGizmo.cs プロジェクト: Aggror/Stride
 public BackgroundGizmo(EntityComponent component)
     : base(component, "Background", GizmoResources.BackgroundGizmo)
 {
 }
コード例 #30
0
ファイル: TestEntity.cs プロジェクト: kiphe19/xenko
 public void OnComponentChanged(Entity entity, int index, EntityComponent oldComponent, EntityComponent newComponent)
 {
     action(new EntityComponentEvent(entity, index, oldComponent, newComponent));
 }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityComponentEventArgs"/> struct.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="componentKey">The component key.</param>
 /// <param name="previousComponent">The previous component.</param>
 /// <param name="newComponent">The new component.</param>
 public EntityComponentEventArgs(Entity entity, int index, EntityComponent previousComponent, EntityComponent newComponent)
 {
     Entity            = entity;
     Index             = index;
     PreviousComponent = previousComponent;
     NewComponent      = newComponent;
 }
コード例 #32
0
 /// <summary>
 /// 自定义的实体显示方法
 /// </summary>
 /// <param name="logicType">实体类型</param>
 /// <param name="entityGroup">实体组</param>
 /// <param name="path">实体路径</param>
 /// <param name="data">实体数据</param>
 public static void ShowCustomEntity(this EntityComponent entityComponent, Type logicType, string entityGroup, string seasonPath, string path, EntityData data)
 {
     entityComponent.ShowEntity(logicType, entityGroup, seasonPath, path, Constant.AssetPriority.GroundModelAsset, data);
 }
コード例 #33
0
 public static void ShowFruit(this EntityComponent entityCompoennt, FruitData data)
 {
     entityCompoennt.ShowEntity(typeof(Fruit), "Fruit", Constant.AssetPriority.FruitAsset, data);
 }
コード例 #34
0
 public static void AttachEntity(this EntityComponent entityComponent, Entity entity, int ownerId, string parentTransformPath = null, object userData = null)
 {
     entityComponent.AttachEntity(entity.Entity, ownerId, parentTransformPath, userData);
 }
コード例 #35
0
 public static void HideEntity(this EntityComponent entityComponent, Entity entity)
 {
     entityComponent.HideEntity(entity.Entity);
 }
コード例 #36
0
 public static EntityComponentReference New(EntityComponent entityComponent)
 {
     return new EntityComponentReference(entityComponent);
 }
コード例 #37
0
ファイル: EntityAnalysis.cs プロジェクト: joewan/xenko
 public EntityLink(ComponentBase referencer, Script script, MemberPath path)
 {
     Referencer = referencer;
     Entity = null;
     EntityScript = script;
     EntityComponent = null;
     Path = path;
 }
コード例 #38
0
ファイル: TestEntity.cs プロジェクト: kiphe19/xenko
 public EntityComponentEvent(Entity entity, int index, EntityComponent oldComponent, EntityComponent newComponent)
 {
     Entity       = entity;
     this.Index   = index;
     OldComponent = oldComponent;
     NewComponent = newComponent;
 }
コード例 #39
0
ファイル: PhysicsGizmo.cs プロジェクト: Aggror/Stride
 public PhysicsGizmo(EntityComponent component) : base(component)
 {
 }
コード例 #40
0
        private static IEnumerator WaitToHide(EntityComponent entityComponent, Entity entity, float fTime)
        {
            yield return(new WaitForSeconds(fTime));

            HideEntity(entityComponent, entity);
        }
コード例 #41
0
 public static void ShowWeapon(this EntityComponent entityComponent, WeaponData data)
 {
     entityComponent.ShowEntity(typeof(Weapon), "Weapon", data);
 }
コード例 #42
0
 internal override void OnEntityComponentRemoved(EntityComponent component)
 {
     base.OnEntityComponentRemoved(component);
 }
コード例 #43
0
 public static void ShowAircraft(this EntityComponent entityComponent, AircraftData data)
 {
     entityComponent.ShowEntity(typeof(Aircraft), "Aircraft", data);
 }
コード例 #44
0
ファイル: TestEntityManager.cs プロジェクト: vvvv/stride
 public CustomEntityComponentEventArgs(CustomEntityComponentEventType type, Entity entity, EntityComponent component)
 {
     Type      = type;
     Entity    = entity;
     Component = component;
 }
コード例 #45
0
 protected void OnComponentAddedEvent(Entity entity, EntityComponent component)
 {
     WatchComponent(component);
     FireRefreshRequest(entity);
 }
コード例 #46
0
 public bool EntityContains <T>(EntityComponent entity) where T : IComponent
 {
     return(_allComponents[TypeRegistry <T> .typeID][(int)entity.id] != null);
 }
コード例 #47
0
 protected virtual void UnwatchComponent(EntityComponent component)
 {
 }
コード例 #48
0
 public T GetComponent <T>(EntityComponent entityID) where T : IComponent
 {
     return((T)_allComponents[TypeRegistry <T> .typeID][(int)entityID.id]);
 }
コード例 #49
0
 public BaseEditor(EntityComponent component, ComponentPropertyItem property)
 {
     Component         = component;
     ComponentProperty = property;
 }
コード例 #50
0
 public static void HideEntity(this EntityComponent entityComponent, Entity entity, float fTime)
 {
     entityComponent.StartCoroutine(WaitToHide(entityComponent, entity, fTime));
 }
コード例 #51
0
 public EntityComponentReference(EntityComponent entityComponent)
 {
     this.entity = new EntityReference { Id = entityComponent.Entity.Id };
     this.component = entityComponent.GetDefaultKey();
     this.value = entityComponent;
 }
コード例 #52
0
 public static void ShowEffect(this EntityComponent entityComponent, EffectData data)
 {
     entityComponent.ShowEntity(typeof(Effect), "Effect", data);
 }
コード例 #53
0
ファイル: EntityAnalysis.cs プロジェクト: joewan/xenko
 public EntityLink(ComponentBase referencer, Entity entity, MemberPath path)
 {
     Referencer = referencer;
     Entity = entity;
     EntityScript = null;
     EntityComponent = null;
     Path = path;
 }
コード例 #54
0
 public static void ShowAsteroid(this EntityComponent entityCompoennt, AsteroidData data)
 {
     entityCompoennt.ShowEntity(typeof(Asteroid), "Asteroid", data);
 }
コード例 #55
0
	void HandleOnActionHitEvent(EntityComponent attacker, EntityComponent target)
	{
		if (hitActionEffectScript != null)
		{
			hitActionEffectScript.Target = target.transform;
			hitActionEffectScript.Visible = true;
			hitActionEffectScript.Play();
		}
	}
コード例 #56
0
 public static void ShowBullet(this EntityComponent entityCompoennt, BulletData data)
 {
     entityCompoennt.ShowEntity(typeof(Bullet), "Bullet", data);
 }
コード例 #57
0
	void HandleOnActionStartedEvent(EntityComponent attacker, EntityComponent target)
	{
		if (startedActionEffectScript != null)
		{
			startedActionEffectScript.Target = target.transform;
			startedActionEffectScript.Visible = true;
			startedActionEffectScript.Play();
		}
	}
コード例 #58
0
 public static void ShowArmor(this EntityComponent entityComponent, ArmorData data)
 {
     entityComponent.ShowEntity(typeof(Armor), "Armor", data);
 }
コード例 #59
0
 public LightSpotGizmo(EntityComponent component)
     : base(component, "Spot", GizmoResources.SpotLightGizmo)
 {
 }
コード例 #60
0
            public static T GetBaseEntity <T>(EntityComponent <T> entityComponent) where T : BaseEntity
            {
                var propertyInfo = entityComponent.GetType().GetProperty("baseEntity", BindingFlags.Instance | BindingFlags.NonPublic);

                return((T)propertyInfo.GetValue(entityComponent, null));
            }