public static GameObject CreateAniResOrOther(string prefabPath, Subject2 owner, UserTriggerDelegate handleFunc) { GameObject gameObject = null; if (!string.IsNullOrEmpty(prefabPath)) { gameObject = RecycleManager.Instance.Instantiate(prefabPath); if (gameObject != null) { AniResource aniRes = gameObject.GetComponent<AniResource>(); if (aniRes != null) { aniRes.owner = owner as Automaton; aniRes.RegisterUserTriggerDelegate(handleFunc); } } if (gameObject == null) { Debug.LogWarning("prefabPath null: [" + prefabPath + "]"); CubeTile.E_Pivot pivot = CubeTile.E_Pivot.BC; if (owner is Projectile) { pivot = CubeTile.E_Pivot.MC; } gameObject = CubeTile.Create(pivot).gameObject; gameObject.transform.localScale = new Vector3(owner.Rect.width, owner.Rect.height, 0); } } return gameObject; }
public static ObjectAnchor Create(Subject2 owner, LayerRect rect, int cullingLayer) { ObjectAnchor ret = new GameObject(owner.GetType().Name).AddComponent<ObjectAnchor>(); ret.gameObject.layer = cullingLayer; ret.SetForcingly("owner", owner); ret.SetForcingly("centerRect", rect.ObjectRectInLayer); ret.transform.parent = rect.point.layer.transform; ret.transform.localPosition = new Vector3(ret.centerRect.x, ret.centerRect.y, 0); return ret; }
public void BuildsUpPrivateFields() { var builder = new StyletIoCBuilder(); builder.Bind <C1>().ToSelf(); var ioc = builder.BuildContainer(); var subject = new Subject2(); ioc.BuildUp(subject); Assert.IsInstanceOf <C1>(subject.GetC1()); }
public void AddSubject(Subject2 subject, float initX, float initY) { subject.SetPosInLayer(this, new Vector2(initX, initY)); subject.CullingLayer = cameraBox.CullingLayer; addTemp.Add(subject); }
public void RemoveSubject(Subject2 subject) { removeTemp.Add(subject); }
// fsm interface public void SetFocusTarget(Subject2 target) { float cameraX = 0f; if (target is HeroCharacter) { float screenPositionRatio = convertHPRatioToScreenPos((target as HeroCharacter).HPRatio); cameraX = screenPositionRatio * Constants.Instance.Field.CameraWidth - Constants.Instance.Field.CameraWidth / 2; } SetHeroChasing(target, cameraX); }
// fsm interface public void PanCameraTo(Subject2 target) { field.FocusOnForced(target, 0); }
// fsm interface public void MoveCameraTo(Subject2 target) { const float targetPos = 0.5f; field.SetFocus(target, targetPos, 30); }
// fsm interface public bool IsInCenter(Subject2 target) { const float threshold = 0.05f; if (target != null) { float posX = target.Rect.point.InBoxPoint.x; return -threshold <= posX && posX <= threshold; } return false; }
private void AddSubject(Subject2 subject) { }
void SetHeroChasing(Subject2 target, float initPos) { cameraChaseTarget = target; if (target != null) { field.FocusOnForced(target, initPos); } }
public void FocusOnForced(Subject2 target, float inBoxOffsetX) { float targetOffsetX = target.Rect.point.InLayerPoint.x - inBoxOffsetX; foreach (var entity in layers) { float ratio = 1; if (layerInfos.ContainsKey(entity.Key)) { ratio = layerInfos[entity.Key].speed; } float offsetX = -targetOffsetX * ratio; float offsetY = 0; if (-1 <= entity.Key && entity.Key <= 1) // ddong { offsetY = -worldClipping.height / 2 + fieldSetting.PlayerOffsetY; } if (layerInfos.ContainsKey(entity.Key)) { offsetY = -worldClipping.height / 2 + layerInfos[entity.Key].offsetY; } Vector2 offset = new Vector2(offsetX, offsetY); offset += CameraEffect.Instance.FlickOffset; entity.Value.coord.SetOffset(offset); } }
public Component1 componentOf; //0..1 public KnowledgeRequestNotification() { classCode="ACT"; moodCode="DEF"; IdList=new List<Id>(); effectiveTime=DateTime.Now; subject1=new Subject(); subject2=new Subject1(); subject3=new Subject2(); subject4List=new List<Subject3>(); componentOf=new Component1(); }
public void FocusOn(Subject2 target, float inBoxOffsetX, float maxSpeed) { float currInBoxX = target.Rect.point.InBoxPoint.x; /* // type 1 { inBoxOffsetX = (currInBoxX + inBoxOffsetX) / 2f; } */ // type 1-1 { float maxDistancePerFrame = maxSpeed * Time.deltaTime; // not using InGameDelta inBoxOffsetX = Mathf.Clamp((currInBoxX + inBoxOffsetX) / 2f, currInBoxX - maxDistancePerFrame, currInBoxX + maxDistancePerFrame); } // type 2 /* { const float maxSpeedPerSec = 50f; float maxSpeedPerFrame = maxSpeedPerSec * TimeTool.InGameDeltaTime; float distance = inBoxOffsetX - currInBoxX; distance = Mathf.Clamp(distance, -maxSpeedPerFrame, maxSpeedPerFrame); inBoxOffsetX = currInBoxX + distance; } * */ // type 3 /* { float maxSpeedPerSec = 50f; float distance = inBoxOffsetX - currInBoxX; if (distance < 4) { maxSpeedPerSec *= Mathf.Sqrt(Mathf.Abs(distance)) / 2; // 2= sqrt(4) } float maxSpeedPerFrame = maxSpeedPerSec * TimeTool.InGameDeltaTime; distance = Mathf.Clamp(distance, -maxSpeedPerFrame, maxSpeedPerFrame); inBoxOffsetX = currInBoxX + distance; } * */ FocusOnForced(target, inBoxOffsetX); }
public StockObserver(string name, Subject2 s) { this.name = name; this.subject = s; }
public void FocusOnForced(Subject2 target, float inBoxOffsetX) { box.FocusOnForced(target, inBoxOffsetX); }
public void SetFocus(Subject2 target, float screenPositionRatio, float maxSpeed) { if (target != null) { float cameraX = screenPositionRatio * Constants.Instance.Field.CameraWidth - Constants.Instance.Field.CameraWidth / 2; box.FocusOn(target, cameraX, maxSpeed); } }
public void BuildsUpPrivateFields() { var builder = new StyletIoCBuilder(); builder.Bind<C1>().ToSelf(); var ioc = builder.BuildContainer(); var subject = new Subject2(); ioc.BuildUp(subject); Assert.IsInstanceOf<C1>(subject.GetC1()); }