public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime) { if (!own.CanMove()) { return(this); } Vector direction = new Vector(); if (GlobalRandom.Generator.Next() % 2 == 0) { direction.x = (float)(GlobalRandom.Generator.NextDouble() - 0.5); } if (GlobalRandom.Generator.Next() % 2 == 0) { direction.z = (float)(GlobalRandom.Generator.NextDouble() - 0.5); } if (direction.Magnitude() != 0.0f) { direction = direction / direction.Magnitude(); } direction = direction * own.RunMaxSpeed; own.SetVelocity(direction.x, direction.y, direction.z); return(new state.Walking(0.5f)); }
public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime) { if (isExecuting) { return(this); } return(new state.Wait(2.0f)); }
public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime) { if (!own.Executioner.ExecuteNormal(now, own)) { return(this); } return(new state.Attacking(own)); }
public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime) { elapsedTime += deltaTime; if (elapsedTime < waitTime) { return(this); } return(new state.ThinkNext()); }
public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime) { elapsedTime += deltaTime; if (elapsedTime < walkTime) { return(this); } own.SetVelocity(0.0f, 0.0f, 0.0f); return(new state.Wait(0.5f)); }
public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime) { var actable = parent.ThinkNext(own, now, deltaTime); return actable.Do(own, now, deltaTime); }
// Update is called once per frame void Update() { Collider[] targets = Physics.OverlapSphere(transform.position, interactRadius, interactable); if (targets.Length == 0) { show = false; } else { if (targets.Length > 1) { targets = targets.OrderBy(c => Vector3.Distance(transform.position, c.transform.position)).ToArray(); } IThinkable iT = targets[0].GetComponent <IThinkable>(); if (iT != null) { switch (iT.Think()) { case 0: ThinkFill.sprite = eKey; show = true; break; case 1: ThinkFill.sprite = fKey; show = true; break; default: show = false; break; } } else { show = false; } } // Fade In if (show) { Color c = ThinkFill.material.color; if (c.a < 1f) { c.a += Time.deltaTime * fadeSpeed; c.a = Mathf.Clamp(c.a, 0f, 1f); ThinkFill.material.color = c; } c = TBSR.material.color; if (c.a < 1f) { c.a += Time.deltaTime * fadeSpeed; c.a = Mathf.Clamp(c.a, 0f, 1f); TBSR.material.color = c; } } else { Color c = ThinkFill.material.color; if (c.a > 0f) { c.a -= Time.deltaTime * fadeSpeed; c.a = Mathf.Clamp(c.a, 0f, 1f); ThinkFill.material.color = c; } c = TBSR.material.color; if (c.a > 0f) { c.a -= Time.deltaTime * fadeSpeed; c.a = Mathf.Clamp(c.a, 0f, 1f); TBSR.material.color = c; } } }
public AIController(IThinkable _thinkable) { thinkable = _thinkable; }