public void Initialize(IGameInterface gameInterface, FDPosition position) { this.gameInterface = gameInterface; this.gameObject.name = "indicator"; this.gameObject.transform.localPosition = FieldTransform.GetObjectPixelPosition(FieldTransform.FieldObjectLayer.Ground, position.X, position.Y); }
internal FieldTransform ToFieldTransform() { var transform = new FieldTransform { FieldPath = FieldPath.EncodedPath }; switch (Kind) { case SentinelKind.ServerTimestamp: transform.SetToServerValue = ServerValue.RequestTime; break; case SentinelKind.ArrayRemove: transform.RemoveAllFromArray = SentinelValue.GetArrayValue(Value); break; case SentinelKind.ArrayUnion: transform.AppendMissingElements = SentinelValue.GetArrayValue(Value); break; case SentinelKind.NumericIncrement: transform.Increment = SentinelValue.GetIncrement(Value); break; default: throw new InvalidOperationException($"Cannot convert sentinel value of kind {Kind} to field transform"); } return(transform); }
private void InitializeObjects() { // Init the cursor gameCursor = new GameObject(); gameCursor.name = string.Format(@"game_cursor"); gameCursor.transform.parent = fieldObjectsRoot; gameCursor.transform.localPosition = FieldTransform.GetObjectPixelPosition(FieldTransform.FieldObjectLayer.Ground, 10, 10); var comp = gameCursor.AddComponent <UICursor>(); comp.Initialize(this); }
public void TouchCursor() { if (currentDialog != null) { return; } FDPosition cursorPosition = FieldTransform.GetObjectUnitPosition(gameCursor.transform.localPosition); // Do the actuall game event gameManager.HandleOperation(cursorPosition); }
public void TouchShape(FDPosition position) { if (currentDialog != null) { return; } // Move the cursor position to the current position FDPosition cursorPosition = FieldTransform.GetObjectUnitPosition(gameCursor.transform.localPosition); gameCursor.transform.localPosition = FieldTransform.GetObjectPixelPosition(FieldTransform.FieldObjectLayer.Ground, position.X, position.Y); }
public void Initialize(IGameInterface gameInterface, Transform field, int chapterId, int shapeIndex, FDPosition position) { this.transform.parent = field; this.gameInterface = gameInterface; this.fieldMapRoot = field; this.chapterId = chapterId; this.shapeIndex = shapeIndex; this.position = position; this.transform.localPosition = FieldTransform.GetShapePixelPosition(position.X, position.Y); }
public override void Update(IGameInterface gameInterface) { if (IsCurrentMoveDone()) { // Set precise position for the UI if (currentVertex >= 0) { var vertex = this.MovePath.Vertexes[currentVertex]; this.UICreature.SetPixelPosition(FieldTransform.GetCreaturePixelPosition(vertex)); } // Pick the next vertex, or finish currentVertex++; if (currentVertex < this.MovePath.Vertexes.Count) { var targetVertex = this.MovePath.Vertexes[currentVertex]; targetPosition = FieldTransform.GetCreaturePixelPosition(targetVertex); FDPosition current = this.UICreature.GetCurrentPosition(); if (targetVertex.X > current.X) { this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkRight); } else if (targetVertex.X < current.X) { this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkLeft); } else if (targetVertex.Y > current.Y) { this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkDown); } else if (targetVertex.Y < current.Y) { this.UICreature.SetAnimateState(UICreature.AnimateStates.WalkUp); } else { // Make the status to done so that next Update will pick the next vertex this.UICreature.SetAnimateState(UICreature.AnimateStates.Idle); } } else { this.UICreature.SetAnimateState(UICreature.AnimateStates.Idle); this.HasFinished = true; } return; } DoMoving(); }
public UICreature PlaceCreature(int creatureId, int animationId, FDPosition position) { GameObject creatureObj = new GameObject(); creatureObj.name = string.Format(@"creature_{0}", creatureId); creatureObj.transform.parent = fieldObjectsRoot; creatureObj.transform.localPosition = FieldTransform.GetCreaturePixelPosition(position); var creatureCom = creatureObj.AddComponent <UICreature>(); creatureCom.Initialize(this, creatureId, animationId); //// creatureCom.SetAnimateState(UICreature.AnimateStates.Dying); return(creatureCom); }
public static DataTransformation GetDataTransformation(this FieldTransform fieldTransform) { switch (fieldTransform) { case FieldTransform.Add: return(DataTransformation.Add); case FieldTransform.Negate: return(DataTransformation.Negate); case FieldTransform.None: return(DataTransformation.None); case FieldTransform.Subtract: return(DataTransformation.Subtract); } throw new NotSupportedException($"FieldTransform Not Supported {fieldTransform}"); }
public void TouchCreature(int creatureId) { if (currentDialog != null) { return; } UICreature creature = GetUICreature(creatureId); FDPosition creaturePosition = creature.GetCurrentPosition(); FDPosition cursorPosition = FieldTransform.GetObjectUnitPosition(gameCursor.transform.localPosition); if (!creaturePosition.AreSame(cursorPosition)) { gameCursor.transform.localPosition = FieldTransform.GetObjectPixelPosition(FieldTransform.FieldObjectLayer.Ground, creaturePosition.X, creaturePosition.Y); } else { // Do the actuall game event gameManager.HandleOperation(creaturePosition); } }
public void RefreshCreature(FDCreature creature) { if (creature == null) { throw new ArgumentNullException("creature"); } UICreature uiCreature = GetUICreature(creature.CreatureId); if (uiCreature == null) { Debug.LogError("Cannot find creature on UI: creatureId = " + creature.CreatureId); return; } // Update position uiCreature.transform.localPosition = FieldTransform.GetCreaturePixelPosition(creature.Position); // Update status uiCreature.SetHasActioned(creature.HasActioned); }
public void Initialize(IGameInterface gameInterface, MenuItemId menuItemId, FDPosition position, FDPosition showUpPosition, bool enabled, bool selected) { this.gameInterface = gameInterface; this.gameObject.name = string.Format(@"menuitem_{0}", menuItemId.GetHashCode()); this.gameObject.transform.localPosition = FieldTransform.GetGroundPixelPosition(showUpPosition); Vector3 menuLocalPosition = FieldTransform.GetGroundPixelPosition(position); MenuSliding sliding = this.gameObject.AddComponent <MenuSliding>(); sliding.Initialize(menuLocalPosition); this.isEnabled = enabled; this.isSelected = selected; this.position = position; this.menuItemId = menuItemId; var box = this.gameObject.AddComponent <BoxCollider>(); box.size = new Vector3(2.4f, 0.2f, 2.4f); box.center = new Vector3(0f, 0.2f, 0f); }
public FDPosition GetCurrentPosition() { return(FieldTransform.GetObjectUnitPosition(this.transform.localPosition)); }