private PathDivision CreateDivision(float xStart) {
		PathDivision division = new GameObject("", typeof(PathDivision)).GetComponent<PathDivision>();
		division.transform.SetParent(transform);
		division.Initialize(path, xStart, xStart + divisionSize);
		division.name = "Path Division (" + ((int)xStart).ToString() + ")";
		division.transform.position = path.bottomContour.GetPointAtX(division.xRange.min);
		return division;
	}
Example #2
0
 /// <summary>
 /// Generates a crowd with the given arguments.
 /// </summary>
 /// <param name="criteria">The crowd's criteria</param>
 /// <param name="isStatic">Are the crowd's members static?</param>
 /// <param name="collection">The crowd's event scheduler.</param>
 public SmartCrowd GenerateCrowd(ISmartCrowdCriteria criteria, bool isStatic, EventCollection collection)
 {
     SmartCrowd instance = new GameObject(NamePrefix + currentCrowdIndex).AddComponent<SmartCrowd>();
     instance.tag = "Smart Object";
     if (Parent != null)
     {
         instance.transform.parent = Parent.transform;
     }
     instance.Initialize(criteria, isStatic, collection);
     instance.Portrait = GetPortrait(currentCrowdIndex);
     currentCrowdIndex++;
     return instance;
 }
Example #3
0
	public IEnumerator Create () {
		if (materials == null) {
			InitializeMaterials();
		}
		if(depth > 0)
			transform.Rotate(Random.Range (-maxTwist, maxTwist), 0f, 0f);
		if(this.GetComponent<MeshFilter>() == null) {
			gameObject.AddComponent<MeshFilter>().mesh = mesh;
			gameObject.AddComponent<MeshRenderer>().material = materials[usedColor];
		}
		if(depth < maxDepth) {
			for (int i = 0; i < childDirections.Length; i++) {
				if(Random.value < spawnProbability || depth == 0) {
					Fractal go = new GameObject("Fractal Child").AddComponent<Fractal>();
					go.Initialize(this, i);
					Vector3 scale = go.transform.localScale;
					go.transform.scaleFrom(.2f,Vector3.zero);
					yield return new WaitForSeconds(.2f);
				}
			}
		}
		if(depth == 0) {		
			FractalMaster = this;
		} else {
			NonMasterFractals.Add(this);
		}
		usedColor ++;
		if(usedColor >= materials.Length) {
			usedColor = 0;
		}
	}
        public IGameObject GetGameObject(string name, float x = 0f, float y = 0f, bool usedAsTemplate = false)
        {
            //If we don't already have a template then generate one first
            if (!gameObjectTemplates.ContainsKey(name))
            {
                var generated = GenerateTemplate(name);

                if (!generated)
                {
                    throw new Exception(string.Format("Could not find a definition for the named game object: {0}", name));
                }
            }

            var template = gameObjectTemplates[name];
            var newObject = new GameObject();//rawPool.New();

            template.CopyInto(newObject);
            newObject.Position = new Vector2(x, y);

            newObject.Initialize();

            if (!usedAsTemplate)
                FireOnGameObjectCreated(newObject);

            return newObject;
        }
Example #5
0
 /// <summary>
 /// initializes objects and adds it to the game field
 /// </summary>
 /// <param name="obj"></param>
 public void AddGameObject(GameObject obj)
 {
     obj.Initialize(Content);
     _newObjects.Add(obj);
 }
Example #6
0
        /* 
		 * 
		 * GameObject's management
		 * 
		 */

        public void SpawnObject(string name, GameObject obj)
        {
            obj.Name = name;
            obj.Engine = this;
            obj.Enabled = true;
            obj.Id = totalObjCount++;
            Objects[name] = obj;
            dirtyObjects[obj] = 1;
            obj.Initialize();
        }
	public virtual GameObject BuildScreen( GUIScreen screen, GUIEditScreenInfo esi )
	{
		GameObject newobj = new GameObject(name);
		if ( newobj != null )
		{
			GUIEditObject eo = newobj.AddComponent(typeof(GUIEditObject)) as GUIEditObject;
			eo.guiScreen = screen;
			eo.name = screen.name;			
			eo.LoadedXML = loadedXML;
			eo.editSI = esi;
			// add all the objects below this
			foreach( GUIObject guiObj in screen.Elements )
				BuildObject(newobj, guiObj);	
			// set game object
			this.screen = newobj;
			// initialize (sets up all skins/styles)
			screen.Initialize(esi.ScreenInfo);
		}
		
		return newobj;
	}
Example #8
0
        public override void Initialize(out GameObject _root)
        {
            _root = new GameObject();
            _root.AddComponent(new EventController());

            m_background = new GameObject();
            m_background.transform.parent = _root.transform;
            _root.GetComponent<EventController>().AddEvent(new Event(m_background.AddComponent(new MenuBackground(m_background1, m_background2, 110f)), "Start", null, 5f));
            m_background.Initialize();

            m_arrow = new GameObject();
            m_arrow.AddComponent(new Animation(new Spritesheet(m_arrowSheet, 8), 0.125f));
            m_arrow.AddComponent(new MusicComponent(m_menuSelect));

            m_menu = new GameObject();
            m_menu.transform.parent = _root.transform;
            m_menu.transform.position += new Vector2(10f, 75f);
            m_menu.AddComponent(new UIMenu(new string[] { "Start Game", "Options", "Tutorial" }, Alignment.Left, 1f, Color.White, m_standartPixelFont, m_arrow));
            _root.GetComponent<EventController>().AddEvent(new Event(m_menu.AddComponent(new Fade(Color.TransparentBlack)), "NewFade", new object[] { Color.White, 1f }, 40f));
            m_menu.Initialize();

            m_blueShip = new GameObject();
            m_blueShip.transform.parent = _root.transform;
            m_blueShip.transform.position = new Vector2(-150, -200f);
            m_blueShip.active = false;
            m_blueShip.AddComponent(new SpriteRenderer(m_blueShipTexture));
            m_blueShip.AddComponent(new MoveObject(new Vector2(5f, -25), Vector2.Zero, (float)Math.PI / 6f, 3f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_blueShip.AddComponent(new Activator()), "Activate", null, 27f));
            m_blueShip.Initialize();

            m_redShip = new GameObject();
            m_redShip.transform.parent = _root.transform;
            m_redShip.transform.position = new Vector2(0, 200f);
            m_redShip.active = false;
            m_redShip.AddComponent(new SpriteRenderer(m_redShipTexture));
            m_redShip.AddComponent(new MoveObject(new Vector2(25f, -10f), Vector2.Zero, (float)Math.PI / 6f, 3f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_redShip.AddComponent(new Activator()), "Activate", null, 28.5f));
            m_redShip.Initialize();

            m_greenShip = new GameObject();
            m_greenShip.transform.parent = _root.transform;
            m_greenShip.transform.position = new Vector2(150f, -50f);
            m_greenShip.active = false;
            m_greenShip.AddComponent(new SpriteRenderer(m_greenShipTexture));
            m_greenShip.AddComponent(new MoveObject(new Vector2(20f, 30f), Vector2.Zero, (float)Math.PI / 6f, 2f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_greenShip.AddComponent(new Activator()), "Activate", null, 31f));
            m_greenShip.Initialize();

            m_title = new GameObject();
            m_title.transform.parent = _root.transform;
            m_title.transform.position -= new Vector2(0f, 20f);
            m_title.AddComponent(new SpriteRenderer(m_titleTexture));
            _root.GetComponent<EventController>().AddEvent(new Event(m_title.AddComponent(new Fade(Color.TransparentBlack)), "NewFade", new object[] { Color.White, 1f }, 37f));
            m_title.Initialize();

            m_subtitle = new GameObject();
            m_subtitle.transform.parent = _root.transform;
            m_subtitle.transform.position += new Vector2(0f, 20f);
            m_subtitle.AddComponent(new SpriteRenderer(m_subtitleTexture));
            _root.GetComponent<EventController>().AddEvent(new Event(m_subtitle.AddComponent(new Fade(Color.TransparentBlack)), "NewFade", new object[] { Color.White, 1f }, 37f));
            m_subtitle.Initialize();

            m_titleMusicObject = new GameObject();
            m_titleMusicObject.transform.parent = _root.transform;
            _root.GetComponent<EventController>().AddEvent(new Event(m_titleMusicObject.AddComponent(new MusicComponent(m_titleMusic)), "Play", null, 4f));
            m_titleMusicObject.Initialize();

            m_segaLogo = new GameObject();
            m_segaLogo.transform.parent = _root.transform;
            m_segaLogo.transform.scale = new Vector2(0.181f, 0.181f);
            m_segaLogo.AddComponent(new Animation(new Spritesheet(m_segaLogoSheet, new Vector2(500, 165)), 0.0825f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_segaLogo.AddComponent(new Fade(Color.White)), "NewFade", new object[] { Color.TransparentBlack, 0.5f }, 3.5f));
            _root.GetComponent<EventController>().AddEvent(new Event(m_segaLogo.AddComponent(new Activator()), "Deactivate", null, 4f));
            m_segaLogo.Initialize();

            m_logo = new GameObject();
            m_logo.transform.parent = _root.transform;
            m_logo.AddComponent(new SpriteRenderer(m_logoTexture));
            Fade logoFade = (Fade)m_logo.AddComponent(new Fade(Color.TransparentBlack));
            _root.GetComponent<EventController>().AddEvent(new Event(logoFade, "NewFade", new object[] { Color.White, 1f }, 9f));
            _root.GetComponent<EventController>().AddEvent(new Event(logoFade, "NewFade", new object[] { Color.TransparentBlack, 1f }, 15f));
            m_logo.Initialize();

            m_presents = new GameObject();
            m_presents.transform.parent = _root.transform;
            m_presents.AddComponent(new UIText("Presents", m_standartPixelFont, Color.White));
            Fade presentsFade = (Fade)m_presents.AddComponent(new Fade(Color.TransparentBlack));
            _root.GetComponent<EventController>().AddEvent(new Event(presentsFade, "NewFade", new object[] { Color.White, 1f }, 16f));
            _root.GetComponent<EventController>().AddEvent(new Event(presentsFade, "NewFade", new object[] { Color.TransparentBlack, 1f }, 22f));
            m_presents.Initialize();

            Game1.LoadScene("AccelCourse.Editor");
        }