Exemplo n.º 1
0
    public string CreateEvent(Vector2 mousePos, Dictionary <Globals.energyTypes, float> _temp)
    {
        /*Dictionary<Globals.energyTypes, float>  energyStored = new Dictionary<Globals.energyTypes, float>();
         * foreach (KeyValuePair<Globals.energyTypes, float> kv in _temp)
         * {
         * }
         */
        float[] tempArr = new float[4];
        foreach (KeyValuePair <Globals.energyTypes, float> kv in _temp)
        {
            tempArr [(int)kv.Key] = kv.Value;
        }


        Dictionary <Globals.energySubTypes, float> subtypeEnergy = SeperateIntoSubtypes(_temp);
        //Debug.Log("here");
        //Now make event!

        EventBrain evBrain = (Instantiate(Resources.Load("EventPrefab"), mousePos, Quaternion.identity) as GameObject).GetComponent <EventBrain>();

        evBrain.Initialize(subtypeEnergy);

        string descriptionOfEvent = new EventDescriber(tempArr).OutputStringRepresentingEvent();

        //GameObject.FindObjectOfType<VillageCenter> ().TheListener.RecordString (descriptionOfEvent);

        //EventDescriber temp = new EventDescriber ();
        return(descriptionOfEvent);
    }
Exemplo n.º 2
0
   public string CreateEvent(Vector2 mousePos,Dictionary<Globals.energyTypes, float> _temp)
   {
       /*Dictionary<Globals.energyTypes, float>  energyStored = new Dictionary<Globals.energyTypes, float>();
       foreach (KeyValuePair<Globals.energyTypes, float> kv in _temp)
       {



       }
		*/
		float[] tempArr = new float[4];
		foreach(KeyValuePair<Globals.energyTypes, float> kv in _temp){
			tempArr [(int)kv.Key] = kv.Value;
		}


		Dictionary<Globals.energySubTypes, float> subtypeEnergy = SeperateIntoSubtypes(_temp);
       //Debug.Log("here");
       //Now make event!
	   
       EventBrain evBrain = (Instantiate(Resources.Load("EventPrefab"), mousePos, Quaternion.identity) as GameObject).GetComponent<EventBrain>();
       evBrain.Initialize(subtypeEnergy);
	   
		string descriptionOfEvent = new EventDescriber (tempArr).OutputStringRepresentingEvent();
		GameObject.FindObjectOfType<VillageCenter> ().TheListener.RecordString (descriptionOfEvent);

		//EventDescriber temp = new EventDescriber ();
		return descriptionOfEvent;
   }
Exemplo n.º 3
0
	public string createEventBluePrint(){
		for (int c = 0; c < 4; c++) {
			bluePrintForEvent [c] = Random.Range (-power / 4, power / 4);
		}
		EventDescriber eventManipulator = new EventDescriber (bluePrintForEvent);
		eventDescription = eventManipulator.OutputStringRepresentingEvent();
		return eventDescription;
	}
Exemplo n.º 4
0
    /*
     * public string CreateRandomEvent(float[] bluePrint, float power){
     *      Dictionary<Globals.energyTypes, float> randomDict = new Dictionary<Globals.energyTypes, float>();
     *      //need to generate float[4] and interpret into energyTypes and add to dictionary
     *      float individualPower = power/4;
     *      float[] temp = {
     *              Random.Range (-individualPower, individualPower),
     *              Random.Range (-individualPower, individualPower),
     *              Random.Range (-individualPower, individualPower),
     *              Random.Range (-individualPower, individualPower)
     *      };
     *
     *      EventDescriber eventManipulator = new EventDescriber (bluePrint);
     *      for (int c = 0; c < 4; c++) {
     *              randomDict.Add ((Globals.energyTypes)c, bluePrint [c]);
     *      }
     *      //x range {-15 --> 15} y range {8 --> -8}
     *      Debug.Log("Event has been created via random method.");
     *      return CreateEvent (new Vector2(Random.Range(-15,15), Random.Range(8,-8)), randomDict);
     * }*/

    public string CreateEventFromFloat(float[] bluePrint)
    {
        Debug.Log("Enter Create Event From Float.");
        Dictionary <Globals.energyTypes, float> randomDict = new Dictionary <Globals.energyTypes, float>();
        EventDescriber eventManipulator = new EventDescriber(bluePrint);

        for (int c = 0; c < 4; c++)
        {
            randomDict.Add((Globals.energyTypes)c, bluePrint [c]);
        }
        //x range {-15 --> 15} y range {8 --> -8}
        Debug.Log("Event has been created via float method: ");
        Debug.Log(Globals.PrintDictionary(randomDict));
        return(CreateEvent(new Vector2(Random.Range(-15, 15), Random.Range(8, -8)), randomDict));
    }
Exemplo n.º 5
0
	public string createEventBluePrint(){
		//Debug.Log ("Creating new blueprint...");
        //return EventFactory.Instance.CreateEventFromFloat(bluePrintForEvent);
		for (int c = 0; c < 4; c++) {
			float tempFloat = Random.Range (-power, power);
			//tempFloat = (Mathf.Abs(tempFloat) < 4)? (tempFloat/Mathf.Abs(tempFloat)) * 4 : tempFloat;
			bluePrintForEvent [c] = tempFloat;
			//Debug.Log ("Counter: " + c + " is equal to " + tempFloat);
		}
		EventDescriber eventManipulator = new EventDescriber (bluePrintForEvent);
		eventDescription = eventManipulator.OutputStringRepresentingEvent();
		//Debug.Log ("New Event Blue Print Description: " + eventDescription);
		//Debug.Log ("Event BluePrint:" + );
		return eventDescription;
	}
Exemplo n.º 6
0
	public string CreateRandomEvent(float[] bluePrint, float power){
		Dictionary<Globals.energyTypes, float> randomDict = new Dictionary<Globals.energyTypes, float>();
		//need to generate float[4] and interpret into energyTypes and add to dictionary
		float individualPower = power/4;
		float[] temp = {
			Random.Range (-individualPower, individualPower),
			Random.Range (-individualPower, individualPower),
			Random.Range (-individualPower, individualPower),
			Random.Range (-individualPower, individualPower)
		}; 

		EventDescriber eventManipulator = new EventDescriber (bluePrint);
		for (int c = 0; c < 4; c++) {
			randomDict.Add ((Globals.energyTypes)c, bluePrint [c]);
		}
		//x range {-15 --> 15} y range {8 --> -8}
		return CreateEvent (new Vector2(Random.Range(-15,15), Random.Range(8,-8)), randomDict);
	}
Exemplo n.º 7
0
    public string createEventBluePrint()
    {
        //Debug.Log ("Creating new blueprint...");
        //return EventFactory.Instance.CreateEventFromFloat(bluePrintForEvent);
        for (int c = 0; c < 4; c++)
        {
            float tempFloat = Random.Range(-power, power);
            //tempFloat = (Mathf.Abs(tempFloat) < 4)? (tempFloat/Mathf.Abs(tempFloat)) * 4 : tempFloat;
            bluePrintForEvent [c] = tempFloat;
            //Debug.Log ("Counter: " + c + " is equal to " + tempFloat);
        }
        EventDescriber eventManipulator = new EventDescriber(bluePrintForEvent);

        eventDescription = eventManipulator.OutputStringRepresentingEvent();
        //Debug.Log ("New Event Blue Print Description: " + eventDescription);
        //Debug.Log ("Event BluePrint:" + );
        return(eventDescription);
    }
Exemplo n.º 8
0
        static void Main()
        {
            var daybreakEventMessage = new BusMessage("daybreak", null);
            var birthdayEventMessage = new BusMessage("birthday", null);

            var mogginsPrevious = new Pet("old moggins", "cat", remainingLimbs: 4);
            var mogginsCurrent  = new Pet("old moggins", "cat", remainingLimbs: 3);

            var robinPrevious = new Person("Robin", age: 35)
            {
                HairColour = "brown", Pets = new[] { mogginsPrevious }
            };
            var robinCurrent = new Person("Robin", age: 36)
            {
                HairColour = "grey", Pets = new[] { mogginsPrevious }
            };

            IEventLogger eventLogger = new EventLogger();

            eventLogger.LogEvent(daybreakEventMessage);

            var childLogger = eventLogger.LogThat(birthdayEventMessage).WasReceived().GetChildLogger();

            childLogger.LogThat(robinPrevious).Became(robinCurrent);

            eventLogger.LogEvent("accident")
            .AndThus(mogginsPrevious)
            .Became(mogginsCurrent);

            var objectDescriber = new ObjectDescriber();
            var eventDescriber  = new EventDescriber(objectDescriber);

            objectDescriber.AddDescriber <Person>(p => new Noun($"{p.Name}"));
            objectDescriber.AddDescriber <Pet>(p => new Noun($"{p.Name} the {p.Species} with {p.RemainingLimbs} leg{(p.RemainingLimbs == 1 ? "" : "s")}"));
            objectDescriber.AddDescriber <IEnumerable <Pet> >(pets => "'" + string.Join(", ", pets.Select(p => objectDescriber.GetNoun(p))) + "'");
            objectDescriber.AddPronoun <Person>(p => Pronouns.Male);
            objectDescriber.AddDescriber <BusMessage>(m => new Noun($"Message of type {m.Type}"));
            eventDescriber.Describe(eventLogger.EventItems()).ToList().ForEach(e => e.PrintToConsole());

            Console.ReadLine();
        }
Exemplo n.º 9
0
	public string CreateEventFromFloat(float[] bluePrint){
		Dictionary<Globals.energyTypes, float> randomDict = new Dictionary<Globals.energyTypes, float>();
		EventDescriber eventManipulator = new EventDescriber (bluePrint);
		for (int c = 0; c < 4; c++) {
			randomDict.Add ((Globals.energyTypes)c, bluePrint [c]);
		}
		//x range {-15 --> 15} y range {8 --> -8}
		return CreateEvent (new Vector2(Random.Range(-15,15), Random.Range(8,-8)), randomDict);
	}
Exemplo n.º 10
0
	/*
	public string CreateRandomEvent(float[] bluePrint, float power){
		Dictionary<Globals.energyTypes, float> randomDict = new Dictionary<Globals.energyTypes, float>();
		//need to generate float[4] and interpret into energyTypes and add to dictionary
		float individualPower = power/4;
		float[] temp = {
			Random.Range (-individualPower, individualPower),
			Random.Range (-individualPower, individualPower),
			Random.Range (-individualPower, individualPower),
			Random.Range (-individualPower, individualPower)
		}; 

		EventDescriber eventManipulator = new EventDescriber (bluePrint);
		for (int c = 0; c < 4; c++) {
			randomDict.Add ((Globals.energyTypes)c, bluePrint [c]);
		}
		//x range {-15 --> 15} y range {8 --> -8}
		Debug.Log("Event has been created via random method.");
		return CreateEvent (new Vector2(Random.Range(-15,15), Random.Range(8,-8)), randomDict);
	}*/

	public string CreateEventFromFloat(float[] bluePrint){
		Debug.Log ("Enter Create Event From Float.");
		Dictionary<Globals.energyTypes, float> randomDict = new Dictionary<Globals.energyTypes, float>();
		EventDescriber eventManipulator = new EventDescriber (bluePrint);
		for (int c = 0; c < 4; c++) {
			randomDict.Add ((Globals.energyTypes)c, bluePrint [c]);
		}
		//x range {-15 --> 15} y range {8 --> -8}
		Debug.Log("Event has been created via float method: ");
		Debug.Log (Globals.PrintDictionary(randomDict));
		return CreateEvent (new Vector2(Random.Range(-15,15), Random.Range(8,-8)), randomDict);
	}
        private EventService CreateService(IEventRepository eventRepository, TestUserRepository userRepo)
        {
            var describers = new EventDescriber[] { new TestEventDescriber() };

            return(new EventService(eventRepository, userRepo, describers));
        }