예제 #1
0
파일: Factory.cs 프로젝트: rbarraud/blarg4
        public override void OnCreate()
        {
            teamEnt = World.current.entities.First(e => e.team == entity.team && e.GetComponent <Team>() != null);

            localBuildRadius = entity.GetComponent <BuildRadius>();
            localCollider    = entity.GetComponent <Collider>();
        }
예제 #2
0
파일: World.cs 프로젝트: rbarraud/blarg4
        public Entity Instantiate(string prototypeName, int team, DVector3 position)
        {
            var proto = entityPrototypes[prototypeName];
            var ent   = new Entity(team, position, proto);

            foreach (var cproto in proto.components)
            {
                Component comp = null;
                if (cproto.kind == "Wizard")
                {
                    comp = new Wizard(ent, cproto);
                }
                else if (cproto.kind == "WizardTower")
                {
                    comp = new WizardTower(ent, cproto);
                }
                else if (cproto.kind == "BasicUnit")
                {
                    comp = new BasicUnit(ent, cproto);
                }
                else if (cproto.kind == "GroundMotor")
                {
                    comp = new GroundMotor(ent, cproto);
                }
                else if (cproto.kind == "AirMotor")
                {
                    comp = new AirMotor(ent, cproto);
                }
                else if (cproto.kind == "ResourceCollectionPoint")
                {
                    comp = new ResourceCollectionPoint(ent, cproto);
                }
                else if (cproto.kind == "ResourceHarvester")
                {
                    comp = new ResourceHarvester(ent, cproto);
                }
                else if (cproto.kind == "Truck")
                {
                    comp = new Truck(ent, cproto);
                }
                else if (cproto.kind == "MineTruck")
                {
                    comp = new MineTruck(ent, cproto);
                }
                else if (cproto.kind == "Mine")
                {
                    comp = new Mine(ent, cproto);
                }
                else if (cproto.kind == "Factory")
                {
                    comp = new Factory(ent, cproto);
                }
                else if (cproto.kind == "ResourceSource")
                {
                    comp = new ResourceSource(ent, cproto);
                }
                else if (cproto.kind == "ProjectileWeapon")
                {
                    comp = new ProjectileWeapon(ent, cproto);
                }
                else if (cproto.kind == "Projectile")
                {
                    comp = new Projectile(ent, cproto);
                }
                else if (cproto.kind == "Collider")
                {
                    comp = new Collider(ent, cproto);
                }
                else if (cproto.kind == "HitscanWeapon")
                {
                    comp = new HitscanWeapon(ent, cproto);
                }
                else if (cproto.kind == "Health")
                {
                    comp = new Health(ent, cproto);
                }
                else if (cproto.kind == "BuildRadius")
                {
                    comp = new BuildRadius(ent, cproto);
                }
                else if (cproto.kind == "Team")
                {
                    comp = new Team(ent, cproto);
                }
                else if (cproto.kind == "ResourcePool")
                {
                    comp = new ResourcePool(ent, cproto);
                }
                else
                {
                    Logger.Log("Unknown component type {0}", cproto.kind);
                }
                ent.AddComponent(comp);
            }
            return(ent);
        }