public void PlayActionDeployment(Transform character, BattleController.DEPLOY_TYPE type) { bool isLeft = type == BattleController.DEPLOY_TYPE.LEFT; GameObject moveObj = GameObject.Instantiate(Prefab_ObjMove) as GameObject; moveObj.name = MOVE_OBJ_NAME; moveObj.transform.parent = character; moveObj.transform.localPosition = isLeft ? MoveObjPositionLeft : MoveObjPositionRight; moveObj.transform.localScale = new Vector3(isLeft ? 1 : -1, 1, 1); Vector3 endPos = character.localPosition; Vector3 startPos = new Vector3(isLeft ? -StartMoveDeltaPosition : StartMoveDeltaPosition , character.localPosition.y, character.localPosition.z); character.localPosition = startPos; iTween.MoveTo(character.gameObject, iTween.Hash("position", endPos, "time", ActionMoveDuration, "delay", 1, "islocal", true, "oncomplete", "onEndMoveAction", "oncompletetarget", this.gameObject, "oncompleteparams", moveObj)); }
private void Deploy(BattleController.DEPLOY_TYPE type, Slots slots) { Transform deployment = type == BattleController.DEPLOY_TYPE.LEFT ? DeploymentLeft : DeploymentRight; if (null == deployment || null == slots) { return; } Transform child; Slot slot; GameObject go; UICharacter characterUIScriptHandler; UIHealthBar healthbarUIScriptHandler; BattleActionController actionController = BattleActionController.Instance; for (int i = 0, count = Mathf.Min(slots.Count, deployment.childCount); i < count; ++i) { child = deployment.GetChild(i); slot = slots[i]; if (!slot.IsEmpty) { go = GameObject.Instantiate(Prefab_Character) as GameObject; go.name = slot.Character.PInfoStats.Name; go.transform.parent = child; go.transform.localPosition = Vector3.zero; //TODO get UICharacter script to do initialize // like sprite.Init( Character character , int deployType ); characterUIScriptHandler = go.GetComponent <UICharacter>(); if (null != characterUIScriptHandler) { characterUIScriptHandler.Init(slot.Index, slot.Character, type); } healthbarUIScriptHandler = go.GetComponent <UIHealthBar>(); if (null != healthbarUIScriptHandler) { healthbarUIScriptHandler.init(slot.Character.PPointStats.Health.Max); } actionController.PlayActionDeployment(go.transform, type); } } StartCoroutine(StartBattle()); }
public void Init(int slotIndex, Character character, BattleController.DEPLOY_TYPE deployType) { if (sprite == null) { return; } if (deployType == BattleController.DEPLOY_TYPE.RIGHT) { sprite.transform.localScale = ScaleLeft; shadow.transform.localScale = ScaleLeft; } this.SlotIndex = slotIndex; ConstantValue.SpriteIdLinker linker = ConstantValue.GetCollectionData(character.SpriteIdTag); tk2dSpriteCollectionData data = linker.GetCollectionData(); sprite.SetSprite(data, linker.SpriteId); shadow.SetSprite(data, linker.ShadowId); }