/// <summary> /// Clear the head from thoughts /// </summary> public void Clear() { Thought pos = _head; _head = null; while(pos != null && pos.Next != null) { pos.Next.Unlink(pos); pos = pos.Next; } }
public ThoughtTwin(double prior) { priorBelief = prior; for (int i = 0; i < N; i++) { thoughts[i] = new Thought(priorBelief); thoughts[i].OpinionChanged += ThoughtTwin_OpinionChanged; } }
public bool IsContraryForThought(Thought thought) { if(thought == null) return false; foreach(PickableObject pickable in thought.ContraryObjects) { if(pickable.Type == Type) return true; } return false; }
public void queueThought(Thought thought) { SpeechEntry entry = new ThoughtSpeechEntry(thought); Debug.Log("Add thought: " + thought.getDescription()); this.textQueue.Add(entry); // Generate and show the bubble Bubble bubble = this.genBubble(); entry.setBubble(bubble); }
public void Merge(Thought.vCards.vCard card) { this.DisplayName = card.GivenName + " " + card.FamilyName; if (card.EmailAddresses.Count > 0) this.Email = card.EmailAddresses.First().Address; var workPhones = card.Phones.Where(x => x.IsCellular); if (workPhones.Count() > 0) this.MobilePhone = workPhones.First().FullNumber; var msgPhones = card.Phones.Where(x => x.IsWork); if (msgPhones.Count() > 0) this.OfficePhone = msgPhones.First().FullNumber; }
/// <summary> /// Remove a thought from the head /// </summary> /// <param name="thought"></param> public void Remove(Thought thought) { if(_head == thought) { _head = _head.Next; } else { Thought pos = _head; while(pos != null && pos.Next != thought) { pos = pos.Next; } if(pos != null && pos.Next == thought) { thought.Unlink(pos); } } }
public ActionResult Convert(Thought thought, string outcome) { var newToDo = new Todo { Title = thought.Name, Outcome = outcome, Topic = Topic.Topics.Find(t => t.Id == thought.Topic.Id ) }; CreateTodo(newToDo); Thought.Thoughts.RemoveAll( thoughtToRemove => thoughtToRemove.Name == thought.Name); return RedirectToAction("Process", "Thought"); }
public override Thought Think() { Thought thought = new Thought(); thought.duck = 0; thought.jump = false; thought.run = 0.25f; if(isTalking == 0 && Time.realtimeSinceStartup - timeToTalk > timeDontTalk) { thought.talk = UnityEngine.Random.Range(1, 19); timeToTalk = Time.realtimeSinceStartup; timeDontTalk = UnityEngine.Random.Range(10.0f, 15.0f); } return thought; }
void Talk(Thought thought) { if (thought.talk > 0 && thought.talk != brain.isTalking) { talkBubble = new GameObject (); Sprite talkSprite = Resources.Load<Sprite> ("Art/Effects/speechbubble"); SpriteRenderer spriteRenderer = talkBubble.AddComponent<SpriteRenderer> (); spriteRenderer.sprite = talkSprite; brain.isTalking = thought.talk; talkBubble.name = "talkBubble"; Destroy(talkBubble, talkStayTime); talkBubble.transform.position = new Vector2 (gameObject.transform.position.x, gameObject.transform.position.y + 20); talkBubble.transform.localScale = new Vector2(1.1f, 1.1f); talkText = new GameObject (); talkText.transform.position = new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y /*+ 20*/, -5.0f); Destroy(talkText, talkStayTime); //talkText.renderer.material.color = Color.black; //talkText.transform.localScale = new Vector2(10, 10); MeshRenderer meshRenderer = talkText.AddComponent<MeshRenderer>(); TextMesh talkLayer = talkText.AddComponent<TextMesh> (); //meshRenderer.material = (Resources.Load("Livingst") as Material); talkText.renderer.material = Resources.Load("arialbd", typeof(Material)) as Material; talkLayer.text = GenerateTalkText(); talkLayer.anchor = TextAnchor.LowerCenter; talkLayer.fontSize = 16; //20; talkLayer.characterSize = 2.0f; talkLayer.renderer.material.color = Color.black; Font myFont = Resources.Load("arialbd", typeof(Font)) as Font; talkLayer.font = myFont; } if (talkBubble) { talkBubble.transform.position = new Vector2 (gameObject.transform.position.x, gameObject.transform.position.y + 20); talkText.transform.position = new Vector3 (gameObject.transform.position.x, gameObject.transform.position.y +13/*+ 20*/, -5.0f); } else { brain.isTalking = 0; } }
void Run(Thought thought) { Rigidbody2D rbody = GetComponent<Rigidbody2D>(); float currVelX = thought.run; if(runSprite && OnGround()) { SpriteRenderer sprRenderer = GetComponent<SpriteRenderer>(); sprRenderer.sprite = runSprite; } rbody.velocity = new Vector2((currVelX + 1.0f) * maxRunSpeed, rbody.velocity.y); myTransform.eulerAngles = new Vector3(0, 0, -rbody.velocity.x/3); }
void Jump(Thought thought) { if (thought.jump) { if (jumpSprite) { SpriteRenderer sprRenderer = GetComponent<SpriteRenderer>(); sprRenderer.sprite = jumpSprite; } Rigidbody2D rbody = GetComponent<Rigidbody2D>(); rbody.velocity = new Vector2(rbody.velocity.x, jumpSpeed); anim.SetTrigger ("Jump"); // choose random jump sound // int jumpSound = (int)UnityEngine.Random.Range(0.0f, 3.9f); Vector3 camPos = GameObject.Find("Main Camera").transform.position; switch (jumpSound) { case 0: AudioSource.PlayClipAtPoint(racerJump1, camPos); break; case 1: AudioSource.PlayClipAtPoint(racerJump2, camPos); break; case 2: AudioSource.PlayClipAtPoint(racerJump3, camPos); break; case 3: AudioSource.PlayClipAtPoint(racerJump4, camPos); break; } // ; } onGround = false; }
float Duck(Thought thought) { if (slideSprite && thought.duck > 0.5f) { SpriteRenderer sprRenderer = GetComponent<SpriteRenderer>(); sprRenderer.sprite = slideSprite; } //myTransform.localScale = new Vector3(startScale.x * (1.0f + thought.duck), startScale.y * (1.0f - thought.duck/2), startScale.z); Rigidbody2D rbody = GetComponent<Rigidbody2D>(); rbody.velocity = new Vector2(rbody.velocity.x, rbody.velocity.y + Physics2D.gravity.y*thought.duck); return thought.duck; }
public void think(Thought t) { this.GetComponent<Speech>().queueThought(t); }
void Awake() { thought = GetComponentInChildren<Thought>(); moveControl = GetComponent<NavMeshAgent>(); moveControl.avoidancePriority = Random.Range(1, 100); supermarket = GameObject.FindGameObjectWithTag("Supermarket").GetComponent<Supermarket>(); spawner = GameObject.FindGameObjectWithTag("Entrance").GetComponent<Spawner>(); gui = GameObject.FindGameObjectWithTag("GUI").GetComponent<GUI>(); listeners = new List<ICustomerStateListener>(); // Find selectionCollider colliders = GetComponentsInChildren<Collider>(); foreach (Collider collider in colliders) { if (collider.tag == "Interactor") { selectionCollider = collider; break; } } }
/// <summary> /// Executes the thoughts work /// </summary> public void Work() { while(true) { int time = _time; Thought head; Thought pos; pos = head = _head; head = _head = Thought.UnlinkJob(_head, time); if(pos == head) { Thread.Sleep(10); continue; } while(pos != null) { Thought next = pos.Next; pos.Unlink(null); try { pos.Trigger(); } catch(Exception e) { ServerConsole.WriteLine(System.Drawing.Color.Red,"Exception in timed callback: {0}", e.Message); if(e.StackTrace != null) { ServerConsole.WriteLine(System.Drawing.Color.Red,e.StackTrace); } ServerConsole.WriteLine(""); } pos = next; } _time = Math.Min(_time, time+5); Thread.Sleep(10); } }
public bool thoughtOk(Thought thought) { return _sinfulThoughts.Contains(thought.ThoughtType); }
/// <summary> /// Requeues the thought with a delta timer /// </summary> /// <param name="delta"></param> /// <param name="thought"></param> public void RequeueDelta(double delta, Thought thought) { thought.TriggerTime += (int)(delta*10); thought.AutoLink(ref _head); }
/// <summary> /// Requeues the thought /// </summary> /// <param name="time"></param> /// <param name="thought"></param> public void Requeue(double time, Thought thought) { thought.TriggerTime = (int)(_time + time *10); thought.AutoLink(ref _head); }
public bool thoughtOk(Thought thought) { return true; }
public override Thought Think() { Thought thought = new Thought(); GamepadState state = GamePad.GetState(whichController); thought.duck = state.LeftStickAxis.y < -0.1f ? -state.LeftStickAxis.y : 0; thought.jump = state.A; thought.run = Math.Min(Math.Max(state.LeftStickAxis.x + state.dPadAxis.x, -1.0f), 1.0f); if(state.X && isTalking == 0) { thought.talk = UnityEngine.Random.Range(0, racerJokes.Length); } return thought; }
public void removeThought(Thought t) { this.thoughts.Remove(t); }
private void StartDriving() { // Set up driving thinker AddAction( 0, 1, time => { if((time % 6) != 0) { UpdateAngle(); UpdatePosition(); } else { float dx, dy; Angles.AngleToDirection(Angle, out dx, out dy); float ahead = 0.0f; // Find where the navigation wants us to go next. int bx = ((int)(X+dx*ahead))/32; int by = ((int)(Y+dy*ahead))/32; if(_game.Navigation.IsBlocked(bx,by)) { bx = ((int)X)/32; by = ((int)Y)/32; } int nextx, nexty; _game.Navigation.FollowStraightPath((int)X,(int)Y, out nextx, out nexty); bool isTarget = _game.Navigation.IsTarget(bx, by); _targetLine.X = X; _targetLine.Y = Y; _targetLine.X2 = nextx; _targetLine.Y2 = nexty; // The vehicle will try to point toward this lookahead point. Currently it's just // the center of the "next" cell. _targetAngle = Util.DeltasToAngle(nextx-X, nexty-Y); _angleDampening += (_targetAngle-_angleDampening) * 0.1f; _angleDampening2 += (_angleDampening-_angleDampening2) * 0.1f; Angle = ((int)(Angle + (_angleDampening2-Angle) * 0.1f)) & 4095; float lastx = X, lasty = Y; UpdatePosition(); var tooCloseObjects =_game.FindObjectsWithinRadius(this,lastx,lasty,40,typeof(Vehicle)); var closeObjects =_game.FindObjectsWithinRadius(this,lastx,lasty,55,typeof(Vehicle)); var closeObjects2 =_game.FindObjectsWithinRadius(this,X,Y,55,typeof(Vehicle)); float colliderDist = float.MaxValue; Vehicle collider = null; foreach(var gob2 in closeObjects2) { foreach(var gob in closeObjects) { if(gob.Object == gob2.Object && gob2.Distance < gob.Distance && gob2.Distance < colliderDist) { collider = (Vehicle)gob2.Object; colliderDist = gob2.Distance; } } } bool iWillDriveAnyway = true; //if(tooCloseObjects. != 0) { int thisMuchOnCourse = Math.Abs(Angles.Difference(Angle,_targetAngle)); foreach(var tco in tooCloseObjects) { var v = (Vehicle)tco.Object; if(v.CurrentThought != Thought.Stopping && Math.Abs(Angles.Difference(v.Angle, _targetAngle)) < thisMuchOnCourse) { iWillDriveAnyway = false; break; } } if(!iWillDriveAnyway) { _targetSpeed = 0; CurrentThought = Thought.Stopping; } } if(iWillDriveAnyway) { if(collider != null) { if(collider.MaxSpeed <= MaxSpeed) { CurrentThought = Thought.Slowing; _targetSpeed = ((Vehicle)collider).Speed; } } else { // Accelerate to reach max velocity and stay there (currently). _targetSpeed = Math.Min(MaxSpeed, _targetSpeed + Acceleration); CurrentThought = Thought.Normal; } } Speed = Util.Lerp(Speed, _targetSpeed, 0.1f); if((time % 10) == 0) { // SpawnDust(); } if(isTarget) { _game.AddObject(new Explosion(_game, X, Y, ExplosionType.Smoky)); _game.RemoveObject(this); return false; } } return true; }); }
public void addThought(Thought t) { this.thoughts.Add(t); this.think (t); }
public AvegaContact(Thought.vCards.vCard card) { Merge(card); }
public ThoughtSpeechEntry(Thought thought) { this.thought = thought; }
public void chainThought(Thought t) { this.nextThought = t; }
/// <summary> /// Recalculates entities in view for each entitie. /// </summary> /// <param name="thought"></param> /// <param name="Params"></param> public static void UpdateEntitiesInView(Thought thought, object[] Params) { lock (typeof(ServerWorld)) { foreach (WorldEntity entity in Entities.Values) { entity.UpdateEntitiesInView(false); } } //requeue Thinker.Requeue(1, thought); }