public void PlayDisk() { if (disks.used.Count > 0) { GameObject disk = disks.used[0]; float x = Random.Range(-10, 10); CCMoveToAction moveToAction = CCMoveToAction.GetSSAction(new Vector3(x, 12, 0), 3 * (Mathf.CeilToInt(FirstSceneController.times / 10) + 1) * Time.deltaTime); seq.Add(moveToAction); this.RunAction(disk, moveToAction, this); disks.used.RemoveAt(0); } if (Input.GetMouseButtonDown(0) && sceneController.flag == 0) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitGameObject; if (Physics.Raycast(ray, out hitGameObject)) { GameObject gameObject = hitGameObject.collider.gameObject; if (gameObject.tag == "disk") { foreach (var k in seq) { if (k.gameObject == gameObject) { k.transform.position = k.target; } } userClickAction = UserClickAction.GetSSAction(); this.RunAction(gameObject, userClickAction, this); } } } base.Update(); }
public void UpBoat(string name) { // if (gameState != GameState.Playing) return; if (boatState != MoveState.AtSrc) { return; } if (passers.Count >= 2) { return; } var list = findRoles(sideSrc, name); if (list.Count == 0) { return; } var role = list[0]; upBoat = CCMoveToAction.GetSSAction(boatPosSrc + new Vector3(0, 1f + spacingOffset, 0) * (passers.Count + 1), roleSpeed); gameState = GameState.Animating; runAction(role, upBoat, this); }
public void passOffBoatToRight() // 同上 { if (boatSize() != 0) { firstScene.nowStatus = Status.rightoff; int pos = boatSize() - 1; boatPass[pos].transform.parent = null; CCMoveToAction moveA = CCMoveToAction.GetSSAction(Shore.rightShoreside, passSpeed); CCMoveToAction moveB; if (boatPassName[pos] == "devil") { moveB = CCMoveToAction.GetSSAction(Devil.rightFirstPosition + Devil.spaceWithTwo * firstScene.rightDevils.Count, passSpeed); // 右边恶魔的动作 firstScene.rightDevils.Push(boatPass[pos]); // 船上恶魔移动到右岸上 } else { moveB = CCMoveToAction.GetSSAction(Priest.rightFirstPosition + Priest.spaceWithTwo * firstScene.rightPriests.Count, passSpeed); // 右岸牧师的动作 firstScene.rightPriests.Push(boatPass[pos]); // 船上牧师移动到右岸上 } rightPassOffBoat = CCSequenceAction.GetSSAction(new List <SSAction> { moveA, moveB }); this.runAction(boatPass[pos], rightPassOffBoat, this); // 进行动作 boatPass[pos] = null; // 清除船上物体 } }
public CCMoveToAction ApplyMoveToAction(GameObject obj, float speed) { CCMoveToAction temp = CCMoveToAction.GetSSAction(speed); base.RunAction(obj, temp, this); return(temp); }
public void onBoat(GameObject man, int type, int i) { if (type == 1) { Vector3 target1 = man.transform.position + new Vector3(0, 1, 0); CCMoveToAction action1 = CCMoveToAction.GetSSAction(target1, 10f); Vector3 target2 = new Vector3(3, 0.8f, 10) + new Vector3(0.6f * (0 - i), 0, 0); CCMoveToAction action2 = CCMoveToAction.GetSSAction(target2, 10f); List <SSAction> sequence = new List <SSAction>(); sequence.Add(action1); sequence.Add(action2); CCSequenceAction ssaction = CCSequenceAction.GetSSAction(0, sequence); this.RunAction(man, ssaction, this); } else if (type == 0) { Vector3 target1 = man.transform.position + new Vector3(0, 1, 0); CCMoveToAction action1 = CCMoveToAction.GetSSAction(target1, 10f); Vector3 target2 = new Vector3(-3, 0.8f, 10) + new Vector3(0.6f * (0 + i), 0, 0); CCMoveToAction action2 = CCMoveToAction.GetSSAction(target2, 10f); List <SSAction> sequence = new List <SSAction>(); sequence.Add(action1); sequence.Add(action2); CCSequenceAction ssaction = CCSequenceAction.GetSSAction(0, sequence); this.RunAction(man, ssaction, this); } }
public void MoveCharacter(GameObject character, Vector3 target, float speed) { Vector3 forward, up, down; float jumpDistance = target.x < 0 ? -8 : 8; List <SSAction> sequence; if (character.transform.position.y > target.y) { forward = target; forward.x += jumpDistance; forward.y = character.transform.position.y; down = target; CCMoveToAction moveForward = CCMoveToAction.GetSSAction(forward, speed); CCMoveToAction jump = CCMoveToAction.GetSSAction(down, speed); sequence = new List <SSAction> { moveForward, jump }; } else { forward = target; up = character.transform.position; up.x += jumpDistance; up.y = target.y; CCMoveToAction moveForward = CCMoveToAction.GetSSAction(forward, speed); CCMoveToAction jump = CCMoveToAction.GetSSAction(up, speed); sequence = new List <SSAction> { jump, moveForward }; } moveCharacter = SequenceAction.GetSSAcition(1, 0, sequence); RunAction(character, moveCharacter, this); }
public void moveBoat(BoatController boat) { CCMoveToAction action = CCMoveToAction.GetSSAction(boat.getDestination(), boat.Speed); // Debug.Log(boat.getDestination()); this.RunAction(boat.getGameobj(), action, this); }
public CCMoveToAction MoveToAction(GameObject obj, float speed) { CCMoveToAction action = CCMoveToAction.GetSSAction(speed); base.RunAction(obj, action, this); return(action); }
protected new void Update() { if (factory.used_ufos.Count > 0) { GameObject disk = factory.used_ufos[0].gameObject; float x = Random.Range(-10, 10); CCMoveToAction moveToAction = CCMoveToAction.GetSSAction(new Vector3(x, 12, 0), (Mathf.CeilToInt(FirstSceneController.times / 10) + 1) * Time.deltaTime); if (disk.transform.GetComponent <Renderer>().material.color == Color.red) { moveToAction = CCMoveToAction.GetSSAction(new Vector3(x, 12, 0), 5 * (Mathf.CeilToInt(FirstSceneController.times / 10) + 1) * Time.deltaTime); } else if (disk.transform.GetComponent <Renderer>().material.color == Color.green) { moveToAction = CCMoveToAction.GetSSAction(new Vector3(x, 12, 0), 4 * (Mathf.CeilToInt(FirstSceneController.times / 10) + 1) * Time.deltaTime); } else if (disk.transform.GetComponent <Renderer>().material.color == Color.blue) { moveToAction = CCMoveToAction.GetSSAction(new Vector3(x, 12, 0), 3 * (Mathf.CeilToInt(FirstSceneController.times / 10) + 1) * Time.deltaTime); } seq.Add(moveToAction); this.RunAction(disk, moveToAction, this); factory.used_ufos.RemoveAt(0); } if (Input.GetMouseButtonDown(0) && sceneController.flag == 0) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitGameObject; if (Physics.Raycast(ray, out hitGameObject)) { GameObject gameObject = hitGameObject.collider.gameObject; if (gameObject.tag == "ufo") { foreach (var k in seq) { if (k.gameObject == gameObject) { k.transform.position = k.target; } } if (gameObject.transform.GetComponent <Renderer>().material.color == Color.red) { userClickAction = UserClickAction.GetSSAction(3); } else if (gameObject.transform.GetComponent <Renderer>().material.color == Color.green) { userClickAction = UserClickAction.GetSSAction(2); } else if (gameObject.transform.GetComponent <Renderer>().material.color == Color.blue) { userClickAction = UserClickAction.GetSSAction(1); } this.RunAction(gameObject, userClickAction, this); } } } base.Update(); }
public void boatRightToLeft() // 如果船在右边并且船上有人,船开向左边 { if (firstScene.nowStatus == Status.eshore && boatSize() != 0) { boatMovetoLeft = CCMoveToAction.GetSSAction(Boat.leftPosition, boatSpeed); this.runAction(firstScene.boat, boatMovetoLeft, this); firstScene.nowStatus = Status.endstart; } }
public void boatLeftToRight() // 如果船在左边并且船上有人,船开向右边 { if (firstScene.nowStatus == Status.sshore && boatSize() != 0) { boatMovetoRight = CCMoveToAction.GetSSAction(Boat.rightPosition, boatSpeed); this.runAction(firstScene.boat, boatMovetoRight, this); firstScene.nowStatus = Status.startend; } }
public void moveCharacter(GameObject role, Vector3 middle_pos, Vector3 end_pos, float speed) { SSAction action1 = CCMoveToAction.GetSSAction(middle_pos, speed); SSAction action2 = CCMoveToAction.GetSSAction(end_pos, speed); CharaMove = CCSequenceAction.GetSSAction(1, 0, new List <SSAction> { action1, action2 }); this.RunAction(role, CharaMove, this); }
public void MoveBoat(GameObject obj, Vector3 target, float speed) { if (isMoving) { return; } isMoving = true; MoveBoatAction = CCMoveToAction.GetSSAction(target, speed); this.RunAction(obj, MoveBoatAction, this); }
public void moveCharacterAction(GameObject character, Vector3 middle_pos, Vector3 end_pos, float speed) { SSAction action1 = CCMoveToAction.GetSSAction(middle_pos, speed); SSAction action2 = CCMoveToAction.GetSSAction(end_pos, speed); ccmoveCharacter = CCSequenceAction.GetSSAction(1, 0, new List <SSAction> { action1, action2 }); //1表示做一次动作,0表示从初始action1开始 this.RunAction(character, ccmoveCharacter, this); }
public void moveRole(GameObject role, Vector3 middle_pos, Vector3 end_pos, float speed) { SSAction action1 = CCMoveToAction.GetSSAction(middle_pos, speed); SSAction action2 = CCMoveToAction.GetSSAction(end_pos, speed); moveRoleToLandorBoat = CCSequenceAction.GetSSAcition(1, 0, new List <SSAction> { action1, action2 }); this.RunAction(role, moveRoleToLandorBoat, this); }
public void MoveRole(GameObject role, Vector3 middlePosition, Vector3 endPosition, float speed) { SSAction step1 = CCMoveToAction.GetSSAction(middlePosition, speed); SSAction step2 = CCMoveToAction.GetSSAction(endPosition, speed); moveRole = CCSequenceAction.GetSSAction(1, 0, new List <SSAction> { step1, step2 }); this.RunAction(role, moveRole, this); sceneController.moving = true; }
public void moveRole(GameObject role, Vector3 target, float speed) { CCMoveToAction moveRoleAction1 = CCMoveToAction.GetSSAction(target, speed); //可能有action2,3... CSequenceAtion actions = CSequenceAtion.GetSSAcition(1, 0, new List <SSAction> { moveRoleAction1 }); this.RunAction(role, actions, this); }
// Use this for initialization protected new void Start() { sceneController = (FirstController)SSDirector.getInstance().currentSceneController; sceneController.actionManager = this; boatToLeft = CCMoveToAction.GetSSAction(new Vector3(-3, 0, 0)); boatToRight = CCMoveToAction.GetSSAction(new Vector3(3, 0, 0)); leftToRight = CCMoveToAction.GetSSAction(new Vector3(2, 2, 0)); leftToLeft = CCMoveToAction.GetSSAction(new Vector3(-4, 2, 0)); rightToRight = CCMoveToAction.GetSSAction(new Vector3(4, 2, 0)); rightToLeft = CCMoveToAction.GetSSAction(new Vector3(-2, 2, 0)); }
public void moveBoat(BoatController boat) { if (boat.getBoatState() == 1) { moveBoatAction = CCMoveToAction.GetSSAction(new Vector3(-2, -0.25f, 0), 10.0f); } else { moveBoatAction = CCMoveToAction.GetSSAction(new Vector3(2, -0.25f, 0), 10.0f); } this.RunAction(sceneController.boat.getBoat(), moveBoatAction, this); }
//移动人 public void MoveRole(GameObject role, Vector3 mid_destination, Vector3 destination, int speed) { if (isMoving) { return; } isMoving = true; moveRoleAction = CCSequenceAction.GetSSAction(0, 0, new List <SSAction> { CCMoveToAction.GetSSAction(mid_destination, speed), CCMoveToAction.GetSSAction(destination, speed) }); this.RunAction(role, moveRoleAction, this); }
public void MoveRole(GameObject role, Vector3 transfer, Vector3 target, float speed) { if (isMoving) { return; } isMoving = true; MoveRoleAction = CCSequenceAction.GetSSAction(0, 0, new List <SSAction> { CCMoveToAction.GetSSAction(transfer, speed), CCMoveToAction.GetSSAction(target, speed) }); this.RunAction(role, MoveRoleAction, this); }
public void moveBoat(GameObject boat, int type) { if (type == 1) { Vector3 target = new Vector3(3, 0, 10); CCMoveToAction action = CCMoveToAction.GetSSAction(target, 3f); this.RunAction(boat, action, this); } else if (type == 0) { Vector3 target = new Vector3(-3, 0, 10); CCMoveToAction action = CCMoveToAction.GetSSAction(target, 3f); this.RunAction(boat, action, this); } }
public void moveMan(GameObject man, int type, int i) { if (type == 1) { Vector3 target = new Vector3(-3 + i * 0.6f, 0.8f, 10); CCMoveToAction action = CCMoveToAction.GetSSAction(target, 3f); this.RunAction(man, action, this); } else if (type == 0) { Vector3 target = new Vector3(3 + i * 0.6f, 0.8f, 10); CCMoveToAction action = CCMoveToAction.GetSSAction(target, 3f); this.RunAction(man, action, this); } }
//追逐玩家 public void moveToPlayer(GameObject gameObj) { //追逐之前先将巡逻方向置为空 int index = getIndex(gameObj); PatrolDirection[index] = -2; gameObj.transform.LookAt(gameObj.transform); //计算追逐的方向 Vector3 chasingDirection = zyzPlayer.transform.position - gameObj.transform.position; //计算移动的目标位置 Vector3 targetPosition = new Vector3(chasingDirection.x, 0, chasingDirection.z); targetPosition += gameObj.transform.position; this.runAction(gameObj, CCMoveToAction.GetSSAction(targetPosition, CHASING_SPEED, true), this); }
public void SSActionEvent(SSAction source, SSActionEventType events = SSActionEventType.Completed, int intParam = 0, string strParam = null, Object objParam = null) { if (source != userAction) { CCMoveToAction cCMoveTo = source as CCMoveToAction; float x = Random.Range(-3.0f, 3.0f); int z = Random.Range(0, 4); Vector3 target = new Vector3(z % 2 == 0 ? (z - 1) * 3.0f : x, 0, z % 2 == 0 ? x : (z - 2) * 3.0f); CCMoveToAction k = CCMoveToAction.GetSSAction(target + cCMoveTo.initPosition, 1.5f, cCMoveTo.initPosition); seq.Remove(cCMoveTo); source.destory = true; seq.Add(k); Quaternion rotation = Quaternion.LookRotation(target + cCMoveTo.initPosition - source.transform.position, Vector3.up); source.transform.rotation = rotation; RunAction(source.gameObject, k, this); } }
protected new void Start() { sceneController = (FirstSceneController)SSDirector.getInstance().currentSceneController; userAction = UserAction.GetSSAction(5); sceneController.actionManager = this; pf = sceneController.pf; RunAction(sceneController.player, userAction, this); foreach (var i in sceneController.patrols) { float x = Random.Range(-3.0f, 3.0f); int z = Random.Range(0, 4); Vector3 target = new Vector3(z % 2 == 0 ? (z - 1) * 3 : x, 0, z % 2 != 0 ? (z - 2) * 3 : x); CCMoveToAction k = CCMoveToAction.GetSSAction(target + i.transform.position, 100, i.transform.position); seq.Add(k); Quaternion rotation = Quaternion.LookRotation(target, Vector3.up); i.transform.rotation = rotation; RunAction(i, k, this); } }
public void rightPriestOnBoat() // 同上 { if (boatSize() != 2 && firstScene.rightPriests.Count != 0) // 船上有空位并且有牧师 { firstScene.nowStatus = Status.rightoff; int pos = (boatPass[0] == null ? 0 : 1); // 看要插入的是左还是右 boatPass[pos] = firstScene.rightPriests.Pop(); // 左岸恶魔移动到船上 boatPassName[pos] = "priest"; // 设置姓名 boatPass[pos].transform.parent = firstScene.boat.transform; // 设置关系 CCMoveToAction moveA = CCMoveToAction.GetSSAction(Shore.rightShoreside, passSpeed); CCMoveToAction moveB = CCMoveToAction.GetSSAction(Boat.rightPosition + (pos == 0 ? Boat.leftSeat : Boat.rightSeat), passSpeed); rightPassOnBoat = CCSequenceAction.GetSSAction(new List <SSAction> { moveA, moveB }); this.runAction(boatPass[pos], rightPassOnBoat, this); } }
public void DownBoat(string name) { // if (gameState != GameState.Playing) return; if (boatState != MoveState.AtDst) { return; } var list = findRoles(passers, name); if (list.Count == 0) { return; } var role = list[0]; downBoat = CCMoveToAction.GetSSAction(groundPosDst + new Vector3(0, 1 + spacingOffset, 0) * (sideDst.Count + 1), roleSpeed); gameState = GameState.Animating; runAction(role, downBoat, this); }
public void MoveCharacter(CharacterController characterCtrl, Vector3 destination) { Vector3 currentPos = characterCtrl.GetPos(); Vector3 middlePos = currentPos; if (destination.y > currentPos.y) { middlePos.y = destination.y; } else { middlePos.x = destination.x; } SSAction action1 = CCMoveToAction.GetSSAction(middlePos, characterCtrl.speed); SSAction action2 = CCMoveToAction.GetSSAction(destination, characterCtrl.speed); SSAction seqAction = CCSequenceAction.GetSSAction(1, 0, new List <SSAction> { action1, action2 }); this.RunAction(characterCtrl.GetGameobj(), seqAction, this); }
public void moveCharacter(ChaController characterCtrl, Vector3 destination) { Vector3 halfDest = destination; Vector3 currentPos = characterCtrl.getPosition(); if (destination.y > currentPos.y) { halfDest.x = currentPos.x; } //上船时转折处理 else { halfDest.y = currentPos.y; } SSAction action1 = CCMoveToAction.GetSSAction(halfDest, characterCtrl.Speed); SSAction action2 = CCMoveToAction.GetSSAction(destination, characterCtrl.Speed); SSAction seqAction = CCSequenceAction.GetSSAction(1, 0, new List <SSAction> { action1, action2 }); this.RunAction(characterCtrl.getCharacter(), seqAction, this); }