public void DoStaticBlowerRegion(MaskData blowerRegion, int deltaX, int deltaZ, int startY, int endY) { for (int i = 0; i < moverCount; i++) { if (moverWeDoNotMove[i]) { continue; } int moverStartX = moverInitialPositions[i].X + moverCharacterPhysics[i].startX; int moverEndX = moverInitialPositions[i].X + moverCharacterPhysics[i].endX; int moverStartY = moverInitialPositions[i].Y; int moverEndY = moverStartY + moverCharacterPhysics[i].height; int moverZ = moverInitialPositions[i].Z; if (blowerRegion.IsSetInXRange(moverStartX, moverEndX, moverZ)) { int groundHeight = GetGroundHeightInXRange(moverStartX, moverEndX, moverZ, moverStartY, moverEndY, moverActors[i], staticOnly: true); bool onGround = (groundHeight == moverStartY); if (!(moverEndY < startY || moverStartY >= endY)) // <- in the blower's Y range { CharacterPhysics.TryMoveHorizontalDidHitWall(ref moverCharacterPhysics[i], this, deltaX, deltaZ, onGround, ref moverActors[i].position, staticOnly: true); } } } }
void Start () { if (setPlayerBoolean) { if (player == null) { player = transform.parent.GetComponent<CharacterPhysics>(); } } }
public void Event(CharacterPhysics otherObj = null, List <CharacterPhysics> physicsObjectList = null) { foreach (var skill in skillList) { if (skill.cType != type) { continue; } var occurStandardObject = characterSkill.GetOccurStandardObject(skill, otherObj); var applyObjList = characterSkill.GetApplyObject(skill, occurStandardObject, otherObj, physicsObjectList); if (applyObjList == null) { Debug.Log("적용될 오브젝트가 없다."); continue; } //충돌된 오브젝트 체크 후 발동 되는지 판단 if (characterSkill.CheckSkill(skill, otherObj)) { //적용될 오브젝트들 모두 체크 var checkObjList = characterSkill.CheckSkill(skill, applyObjList); foreach (var obj in checkObjList) { //선발된 오브젝트들만 스킬 적용 characterSkill.ApplySkill(skill, occurStandardObject, obj); } } } }
protected override void Awake() { base.Awake(); _animator = GetComponentInChildren<Animator>(); _physics = GetComponent<CharacterPhysics>(); // No point in continuing if an animator if (_animator == null) { enabled = false; Debug.LogWarning("Character Animator could not find a Animator component under " + name); return; } _grounded.Animator = _animator; _helpless.Animator = _animator; _verticalSpeed.Animator = _animator; _horizontalSpeed.Animator = _animator; _jump.Animator = _animator; _airJump.Animator = _animator; _attack.Animator = _animator; _horizontalInput.Animator = _animator; _verticalInput.Animator = _animator; _grounded.Set(Character.IsGrounded); if (Character == null) return; // Subscribe to Character events Character.OnGrounded += OnGrounded; Character.OnJump += OnJump; Character.OnAttack += OnAttack; }
public IEnumerator EventCoroutine(CharacterPhysics otherObj = null, List <CharacterPhysics> physicsObjectList = null) { foreach (var skill in skillList) { if (skill.cType != type) { continue; } yield return(PhysicsManager.Instance.StartPhysicsCoroutine( characterSkill.GetOccurStandardObjectCoroutine(skill, otherObj))); var occurStandardObject = characterSkill.occurStandardObject; var applyObjList = characterSkill.GetApplyObject(skill, occurStandardObject, otherObj, physicsObjectList); if (applyObjList == null) { Debug.Log("적용될 오브젝트가 없다."); continue; } //충돌된 오브젝트가 있을수도 있고 없을수도 있다. var checkObjList = characterSkill.CheckSkill(skill, applyObjList); foreach (var obj in checkObjList) { characterSkill.ApplySkill(skill, occurStandardObject, obj); } } }
public void DoStaticGroundConveyorRegion(MaskData conveyorRegion, int deltaX, int deltaZ) { for (int i = 0; i < moverCount; i++) { if (moverWeDoNotMove[i]) { continue; } int moverStartX = moverInitialPositions[i].X + moverCharacterPhysics[i].startX; int moverEndX = moverInitialPositions[i].X + moverCharacterPhysics[i].endX; int moverY = moverInitialPositions[i].Y; int moverZ = moverInitialPositions[i].Z; if (conveyorRegion.IsSetInXRange(moverStartX, moverEndX, moverZ)) { int groundHeight = GetGroundHeightInXRange(moverStartX, moverEndX, moverZ, moverY, moverY + moverCharacterPhysics[i].height, moverActors[i], staticOnly: true); if (moverY == groundHeight) // <- on the ground { CharacterPhysics.TryMoveHorizontalDidHitWall(ref moverCharacterPhysics[i], this, deltaX, deltaZ, true, ref moverActors[i].position, staticOnly: true); } } } }
public void StopPhysicsObj(CharacterPhysics obj) { obj.speed = 0; obj.dir = Vector3.zero; obj.character.InitState(); }
public CharacterPhysics GetNearCharacter(List <CharacterPhysics> physicsObjectList) { float nearDistance = -1; CharacterPhysics findObj = null; foreach (var obj in physicsObjectList) { if (obj.PID == character.Physics.PID) { continue; } var dis = Vector3.Distance( characterTransform.localPosition, obj.characterTransform.localPosition); if (dis < nearDistance || nearDistance == -1) { nearDistance = dis; findObj = obj; } } return(findObj); }
public CharacterPhysics GetOccurStandardObject(SkillData skill, CharacterPhysics collisionObj) { occurStandardObject = null; switch (skill.occurStandard) { case 0: { Debug.Log(string.Format("{0}의 OccurStandardObject : {1} (본인)", characterTransform.name, skill.occurStandard)); occurStandardObject = character.Physics; break; } case 1: { Debug.Log(string.Format("{0}의 OccurStandardObject : {1} (충돌 된 상대)", characterTransform.name, skill.occurStandard)); occurStandardObject = collisionObj; break; } case 2: { Debug.Log(string.Format("{0}의 OccurStandardObject : {1} (위치 직접 지정)", characterTransform.name, skill.occurStandard)); break; } } return(occurStandardObject); }
protected virtual void initializeCapacities() { physics = GetComponent <CharacterPhysics>(); input = GetComponent <CharacterInput>(); move = GetComponent <CharacterMove>(); jump = GetComponent <CharacterJump>(); groundDetector = GetComponent <CharacterGroundDetection>(); }
/// <summary> Adds all of the colliderObjects to a handy dictionary named collToPart. /// Also determines the length of this body part by looking at all of these colliders, /// thenceby setting _topVector </summary> /// <param name="characterPhysics">The parent CharacterPhysics class</param> internal void Initialize(CharacterPhysics characterPhysics) { _pp = characterPhysics; if (parentPart != null) { _parent = _pp.bodyParts.First(part => part.bodyPart == parentPart); } _rb = _pp.gameObject.GetComponent <Rigidbody2D>(); _root = _pp.transform; Vector3 objPos = bodyPart.transform.position; Vector3 farPoint = objPos; Collider2D farColl = bodyPart.GetComponent <Collider2D>(); foreach (GameObject co in colliderObjects) { Collider2D[] colliders = co.GetComponents <Collider2D>(); foreach (Collider2D collider in colliders) { if (Vector3.Distance(collider.bounds.center, objPos) >= Vector3.Distance(farPoint, objPos)) { farPoint = collider.bounds.center; farColl = collider; } _pp.collToPart.Add(collider, this); } } farPoint = Vector3.Distance(farPoint + farColl.bounds.extents, objPos) < Vector3.Distance(farPoint - farColl.bounds.extents, objPos) ? bodyPart.transform.InverseTransformPoint(farPoint - farColl.bounds.extents) : bodyPart.transform.InverseTransformPoint(farPoint + farColl.bounds.extents); _topVector = new Vector3(farPoint.x, 0); if (lowerLimit < -360) { float old = lowerLimit; lowerLimit %= 360; upperLimit += lowerLimit - old; } if (upperLimit > 720) { float old = upperLimit; upperLimit %= 360; lowerLimit += upperLimit - old; } if (isLeg) { // _pp.StartCoroutine(_CheckStep()); //TODO FIXME Checkstep is dumb and bad and needs to be made less bad List <GameObject> partsTemp = _pp._nonLegBendParts.ToList(); List <float> amountsTemp = _pp._nonLegBendAmounts.ToList(); partsTemp.AddRange(bendParts); amountsTemp.AddRange(bendAmounts); _pp._nonLegBendParts = partsTemp.ToArray(); _pp._nonLegBendAmounts = amountsTemp.ToArray(); } }
void Start() { mCP = GetComponent <CharacterPhysics>(); mCollider = GetComponent <Collider>(); mMR = GetComponent <MeshRenderer>(); mCC = GetComponent <CharacterController>(); mWalkLayer = 1 << LayerMask.NameToLayer("WalkOn"); transform.rotation = Quaternion.Euler(0, Random.Range(0.0f, 360.0f), 0); }
// Use this for initialization void Start() { gc = GetComponent <GameControl>(); ch = GameObject.Find("Character").GetComponent <Character>(); chp = GameObject.Find("Character").transform.Find("Sprite").GetComponent <CharacterPhysics>(); canvasRect = GameObject.Find("UICanvas").GetComponent <RectTransform>(); gameStartText.text = ""; StartCoroutine(GameStart()); }
public IEnumerator GetOccurStandardObjectCoroutine(SkillData skill, CharacterPhysics collisionObj) { occurStandardObject = null; switch (skill.occurStandard) { case 0: { Debug.Log(string.Format("{0}의 OccurStandardObject : {1} (본인)", characterTransform.name, skill.occurStandard)); occurStandardObject = character.Physics; break; } case 1: { Debug.Log(string.Format("{0}의 OccurStandardObject : {1} (충돌 된 상대)", characterTransform.name, skill.occurStandard)); occurStandardObject = collisionObj; break; } case 2: { Debug.Log(string.Format("{0}의 OccurStandardObject : {1} (위치 직접 지정)", characterTransform.name, skill.occurStandard)); var findPID = PhysicsManager.Instance.FindFirstCollision(character.Physics.PID); //첫 충돌한 기록은 있지만 if (findPID != -1) { //그 오브젝트가 비활성화(삭제대기) 상태라면 var findObj = PhysicsManager.Instance.GetPhysicsObject(findPID); if (findObj.isInActive) { //오픈된 모든 UI들을 숨기고 UIManager.Instance.SetAllActive(false); //위치 지정 UI 오픈 var selectUI = UIManager.Instance.Get <PositionSelectUI>() as PositionSelectUI; selectUI.Init(skill.desc, findObj); //위치를 지정할때 까지 기다린다. yield return(PhysicsManager.Instance.StartPhysicsCoroutine( selectUI.WaitSelectPosition())); //위치가업데이트 된 오브젝트를 받아온다 occurStandardObject = selectUI.newPosObj; //위치 지정 UI를 닫고 selectUI.Close(); //다시 오픈 된 UI들을 활성화 UIManager.Instance.SetAllActive(true); } } break; } } }
public void Init(string title, CharacterPhysics obj) { this.newPosObj = obj; this.isClick = false; titleLabel.text = title; CameraManager.IsFixed = false; }
public void Initialize() { if (GetComponent <CharacterData>() != null) { playerPrefix = "P" + (GetComponent <CharacterData>().PlayerIndex + 1).ToString(); } if (GetComponent <CharacterPhysics>() != null) { characterPhysics = GetComponent <CharacterPhysics>(); } }
private void Awake() { _physics = GetComponent <CharacterPhysics>(); _animation = new AnimationManager(GetComponent <Animator>()); _weapon = transform.GetComponentInChildren <IWeaponPlatformer>(); ((IWearable)_weapon)?.SetOwner(this); Life.Reset(); Life.OnDie += OnDie; OnAwake(); }
public void AddPhysicsObject(CharacterPhysics obj) { //가장 마지막 데이터의 다음 id 부여 var firstData = physicsObjectList.LastOrDefault(); var newPID = firstData != null ? firstData.PID + 1 : 0; //인덱스 부여 후 obj.SetPID(newPID); //리스트에 추가 physicsObjectList.Add(obj); Debug.Log(string.Format("" + "[AddPhysicsObject]\n" + "이름 : {0} / PID : {1} / 등급 : {2} / 이름 : {3}", obj.characterTransform.name, obj.PID, obj.character.Data.rarity, obj.character.Data.name)); }
public static MotionResult PhysicsStepHorizontal(ref CharacterPhysicsInfo cpi, ref Position position, ref ThreeDVelocity velocity, bool onGround, int coefficientOfRestitution256, int groundFriction256, WorldPhysics physics) { MotionResult result = MotionResult.None; int newPositionX = velocity.X.Update(position.X); int newPositionZ = velocity.Z.Update(position.Z); int deltaX = newPositionX - position.X; int deltaZ = newPositionZ - position.Z; if (deltaX != 0) { if (CharacterPhysics.TryMoveHorizontalDidHitWall(ref cpi, physics, deltaX, 0, onGround, ref position)) { // Hit wall, bounce: velocity.X.Scale256(-coefficientOfRestitution256); result = MotionResult.HitWall; } } // Z-motion just stops if it hits anything if (deltaZ != 0 && CharacterPhysics.TryMoveHorizontalDidHitWall(ref cpi, physics, 0, deltaZ, onGround, ref position)) { velocity.Z.Reset(); // NOTE: Currently not even bothering to give a hit result, just carry on... } // TODO: Slope handling for rolling objects if (onGround) { // Friction: velocity.X.Scale256(groundFriction256); velocity.Z.Scale256(groundFriction256); } return(result); }
private void Awake() { //init: animator = GetComponent <Animator>(); input = GetComponent <AbstractCharacterInput>(); if (input == null) { input = gameObject.AddComponent <AbstractCharacterInput>(); } physics = GetComponent <CharacterPhysics>(); if (physics == null) { physics = gameObject.AddComponent <CharacterPhysics>(); } view = GetComponent <AbstractCameraController>(); if (view == null) { view = gameObject.AddComponent <AbstractCameraController>(); } interaction.init(); ResetAnimatorController(); }
protected virtual void Awake() { //References rb = GetComponent <Rigidbody2D>(); characterPhysics = GetComponent <CharacterPhysics>(); control = GetComponent <CharacterControlAbstract>(); movement = GetComponent <MovementAbstract>(); anim = GetComponent <Animator>(); characterStats = Instantiate(characterStats); //create local instance that can be modified statusIndicator?.SubscribeToChangeEvents(characterStats); characterStats.Initialize(); faction = characterFaction.GetHashCode(); if (weapon != null) { weapon.OnEquip(this); } }
// Use this for initialization void Start() { phys = GetComponent<CharacterPhysics> (); gravity = -2 * jumpHeight / Mathf.Pow (timeToJumpApex, 2); jumpVelocity = -gravity * timeToJumpApex; //animator animator = GetComponent<Animator>(); }
public static MotionResult PhysicsStepVertical(ref CharacterPhysicsInfo cpi, ref Position position, ref ThreeDVelocity velocity, ref bool onGround, int coefficientOfRestitution256, int gravityUp256, int gravityDown256, bool lockVertical, WorldPhysics physics, bool groundIsAPit) { if (lockVertical) { velocity.Y.Reset(); } else { if (velocity.Y.Velocity256 > 0) // Moving upwards { onGround = false; int startY = position.Y + cpi.height; position.Y = velocity.Y.Update(position.Y, gravityUp256); int endY = position.Y + cpi.height; if (endY > startY) { int ceiling = physics.GetCeilingHeightInXRange(position.X + cpi.startX, position.X + cpi.endX, position.Z, startY, endY, cpi.owner); if (ceiling < endY) // Hit ceiling { position.Y = ceiling - cpi.height; velocity.Y.Velocity256 = -((velocity.Y.Velocity256 * coefficientOfRestitution256) >> 8); // <- Bounce (fixed-point multiply) return(MotionResult.HitCeiling); } } } else // Moving downwards { int groundHeight = CharacterPhysics.GroundHeight(ref cpi, physics, position); if (position.Y > groundHeight) { onGround = false; // we came off the ground } else if (position.Y < groundHeight) // TODO: This needs some rethinking (added to let separation do its thing) { onGround = true; // we are embedded in the ground (we may start physics in this state, if we are put here by teleport/animation) } else if (position.Y == groundHeight && velocity.Y.Velocity256 == 0) { onGround = true; // we were gently placed on the ground (don't trigger OnHitGround) } if (!onGround) { position.Y = velocity.Y.Update(position.Y, gravityDown256); if (position.Y <= groundHeight) // Hit the ground { position.Y = groundHeight; if (groundHeight == 0 && groundIsAPit) { velocity = new ThreeDVelocity(); return(MotionResult.HitBottomOfPit); } else if (velocity.Y.Velocity256 > -128) // <- Kill velocity of we're moving too slowly downwards (start rolling) { onGround = true; velocity.Y.Reset(); } else { onGround = false; velocity.Y.Scale256(-coefficientOfRestitution256); velocity.X.Scale256(coefficientOfRestitution256); velocity.Z.Scale256(coefficientOfRestitution256); } return(MotionResult.HitGround); } } } } return(MotionResult.None); }
public IEnumerator AllStopEvent(CharacterPhysics firstCollisionObj, List <CharacterPhysics> physicsObjectList) { yield return(PhysicsManager.Instance.StartPhysicsCoroutine(allStopEvent.EventCoroutine(firstCollisionObj, physicsObjectList))); }
public void BeCollidedEvent(CharacterPhysics otherObj, List <CharacterPhysics> physicsObjectList) { beCollidedEvent.Event(otherObj, physicsObjectList); }
public void DoSeparation(UpdateContext updateContext) { // // Process anyone requesting to be updated before separation // foreach (var i in collidersToUpdateBeforeSeparation) { Actor actor = (Actor)colliderEntries[i].owner; // <- will always succeed, because we registered it that way HeightmapView heightmapView = new HeightmapView(actor.animationSet.Heightmap, actor.position, actor.facingLeft); ChangeCollider(i, heightmapView); } // // Remove everyone from static geometry // for (int i = 0; i < moverCount; i++) { if (moverWeDoNotMove[i]) { continue; } if (moverActors[i].IncomingConnection != null) { continue; // Don't separate if we're attached to someone } var cpi = moverCharacterPhysics[i]; int simpleGroundHeight = CharacterPhysics.GroundHeight(ref cpi, this, moverActors[i].position, true); if (simpleGroundHeight <= moverActors[i].position.Y) { continue; // We are in open space } // // Oh no! We are stuck in the level! // // Attempt 1: Move back to start point, and then try moving to new position: // (Doing this first, to try to prevent tunneling behaviour - also probably faster than TryToFitNearestInZSlice) Position moveDelta = moverActors[i].position - moverInitialPositions[i]; if (moveDelta != Position.Zero && // <- Can't undo non-moves. moveDelta.ManhattenLength <= 8) // <- Don't try to undo huge moves, as they may be teleports/animations, and we could get snagged on the way there. { var groundHeightAtInitial = CharacterPhysics.GroundHeight(ref cpi, this, moverInitialPositions[i], true); if (groundHeightAtInitial <= moverInitialPositions[i].Y) // <- OK at initial position { // Attempt to move towards target: Position target = moverActors[i].position; moverActors[i].position = moverInitialPositions[i]; CharacterPhysics.TryMove(ref moverCharacterPhysics[i], this, moveDelta, false, ref moverActors[i].position, true); continue; // Success! } } // Attempt 2: Attempt to extricate ourselves from the situation directly #region // a whole bunch of code { int statsZSliceCount = 0; long statsVoxelCount = 0; Position desiredPosition = moverActors[i].position; // Ensure we didn't come out of the level entirely if (desiredPosition.X < StartX) { desiredPosition.X = StartX; } if (desiredPosition.X >= EndX) { desiredPosition.X = EndX - 1; } if (desiredPosition.Y < 0) { desiredPosition.Y = 0; } if (desiredPosition.Z < StartZ) { desiredPosition.Z = StartZ; } if (desiredPosition.Z >= EndZ) { desiredPosition.Z = EndZ - 1; } // Grab the nearest point on our current plane: const int maxRadiusXY = 128; Point nearest = TryToFitNearestInZSlice(moverCharacterPhysics[i].startX, moverCharacterPhysics[i].endX, moverCharacterPhysics[i].height, desiredPosition.X, desiredPosition.Y, moverActors[i].position.Y, desiredPosition.X - maxRadiusXY, desiredPosition.X + maxRadiusXY, desiredPosition.Z, desiredPosition.Y - maxRadiusXY, desiredPosition.Y + maxRadiusXY, moverActors[i], true); statsZSliceCount++; statsVoxelCount += (maxRadiusXY * maxRadiusXY * 4); Position bestPosition; int bestDistance; if (nearest != NoFitFound) { bestDistance = Math.Abs(desiredPosition.X - nearest.X) + Math.Abs(desiredPosition.Y - nearest.Y); bestPosition = new Position(nearest.X, nearest.Y, desiredPosition.Z); // Debugging: If check that we're not ending up back in the same place (why did we try to separate, if we fit?) // If this assert fires, there is a bug in the separation algorithm. // NOTE: checks vs non-clipped position! Debug.Assert(Position.ManhattenDistance(moverActors[i].position, bestPosition) > 0, "SEPARATION DID NOTHING. Actor is: " + moverActors[i].ToString() + "\n\nIf you can reproduce this, please report to Andrew. Otherwise hit \"Ignore\" and carry on."); } else { bestPosition = default(Position); bestDistance = int.MaxValue; } // Search forwards and backwards for better positions on nearby planes: const int maxRadiusZ = 10; int searchBoundStartZ = Math.Max(StartZ, desiredPosition.Z - maxRadiusZ); int searchBoundEndZ = Math.Min(EndZ, desiredPosition.Z + maxRadiusZ); // Searching forwards: (NOTE: Copy-paste with searching backwards) int searchZ = desiredPosition.Z - 1; // NOTE: Checking vs bestDistance each time, so we might be able to early-out while (searchZ >= searchBoundStartZ && (desiredPosition.Z - searchZ) < bestDistance) // <- IMPORTANT: not doing maths on bestDistance, as it can be int.MaxValue! { Debug.Assert(bestDistance > 0); int radiusXY = Math.Min(bestDistance, maxRadiusXY); // <- hopefully reduces search range nearest = TryToFitNearestInZSlice(moverCharacterPhysics[i].startX, moverCharacterPhysics[i].endX, moverCharacterPhysics[i].height, desiredPosition.X, desiredPosition.Y, moverActors[i].position.Y, desiredPosition.X - radiusXY, desiredPosition.X + radiusXY, searchZ, desiredPosition.Y - radiusXY, desiredPosition.Y + radiusXY, moverActors[i], true); statsZSliceCount++; statsVoxelCount += (radiusXY * radiusXY * 4); if (nearest != NoFitFound) { int distance = Math.Abs(desiredPosition.X - nearest.X) + Math.Abs(desiredPosition.Y - nearest.Y) + Math.Abs(desiredPosition.Z - searchZ); if (distance < bestDistance) { bestDistance = distance; bestPosition = new Position(nearest.X, nearest.Y, searchZ); } } searchZ--; } // Searching backwards: (NOTE: Copy-paste with searching forwards) searchZ = desiredPosition.Z + 1; // NOTE: Checking vs bestDistance each time, so we might be able to early-out while (searchZ < searchBoundEndZ && (searchZ - desiredPosition.Z) < bestDistance) // <- IMPORTANT: not doing maths on bestDistance, as it can be int.MaxValue! { Debug.Assert(bestDistance > 0); int radiusXY = Math.Min(bestDistance, maxRadiusXY); // <- hopefully reduces search range nearest = TryToFitNearestInZSlice(moverCharacterPhysics[i].startX, moverCharacterPhysics[i].endX, moverCharacterPhysics[i].height, desiredPosition.X, desiredPosition.Y, moverActors[i].position.Y, desiredPosition.X - radiusXY, desiredPosition.X + radiusXY, searchZ, desiredPosition.Y - radiusXY, desiredPosition.Y + radiusXY, moverActors[i], true); statsZSliceCount++; statsVoxelCount += (radiusXY * radiusXY * 4); if (nearest != NoFitFound) { int distance = Math.Abs(desiredPosition.X - nearest.X) + Math.Abs(desiredPosition.Y - nearest.Y) + Math.Abs(desiredPosition.Z - searchZ); if (distance < bestDistance) { bestDistance = distance; bestPosition = new Position(nearest.X, nearest.Y, searchZ); } } searchZ++; } #if DEBUG // Separation stats { bool isActuallyTheMainSimulation = (updateContext.DebugNetworkUnsafeHasLocalSettings); // <- Somewhat hacky mechanisim so we don't get debug writes for "alternate universes" when debugging if (isActuallyTheMainSimulation) { Debug.WriteLine("Separation of \"" + moverActors[i] + "\" searched " + statsZSliceCount + " Z slices, checking " + statsVoxelCount + " voxels; moved from " + moverActors[i].position + " to " + bestPosition + "."); } } #endif if (bestDistance != int.MaxValue) // <- Did we find a suitable position? { moverActors[i].position = bestPosition; continue; } } #endregion // // At this point... holy crap... how did you manage to get an object here?? // stuckObjects.Add(moverActors[i]); // <- game state can deal with it. } }
/// <summary>Get the Y position of the ground for this actor.</summary> public int GroundHeight(WorldPhysics physics) { var cpi = new CharacterPhysicsInfo(animationSet, this); return(CharacterPhysics.GroundHeight(ref cpi, physics, position)); }
public SkillCollect(Scene scene, Character character, CharacterPhysics physics, int cooldown) : base(scene, character, cooldown) { this.physics = physics; this.charSheet = character.getRepresentation() as Spritesheet; }
public List <CharacterPhysics> GetCharacterInRange(float angleValue, float rangeValue, CharacterPhysics occurStandardObj, CharacterPhysics collisionObj, List <CharacterPhysics> physicsObjectList) { List <CharacterPhysics> findObjList = null; Vector3 dir = Vector3.zero; if (occurStandardObj == null) { return(findObjList); } if (collisionObj != null) { dir = Vector3.Normalize( collisionObj.characterTransform.localPosition - characterTransform.localPosition); } rangeValue = (rangeValue * GameManager.DISTACNE) + occurStandardObj.Radius; foreach (var obj in physicsObjectList) { if (obj.PID == occurStandardObj.PID) { continue; } var dis = Vector3.Distance( occurStandardObj.characterTransform.localPosition, obj.characterTransform.localPosition); var targetDir = Vector3.Normalize( obj.characterTransform.localPosition - occurStandardObj.characterTransform.localPosition); var angle = Vector3.Angle(dir, targetDir); if (angle <= angleValue && dis <= rangeValue) { if (findObjList == null) { findObjList = new List <CharacterPhysics>(); } findObjList.Add(obj); } } return(findObjList); }
private void OnEnable() { _t = (CharacterPhysics)target; _getTarget = new SerializedObject(_t); _bodyParts = _getTarget.FindProperty(nameof(CharacterPhysics.bodyParts)); // Find the List in our script and create a refrence of it }
public void ApplySkill(SkillData skillData, CharacterPhysics occurStandardObj, CharacterPhysics applyObj) { Debug.Log(string.Format("{0}의 스킬 발동 {1} -> {2}\n{3}", characterTransform.name, occurStandardObj.characterTransform.name, applyObj.characterTransform.name, skillData.desc)); var applyCharacter = applyObj.character; switch (skillData.applyType) { case 1: //공격력 { var value = GetApplyValueType(skillData.applyValueType, applyCharacter.finalAttack, character); var finalValue = value * skillData.applyValue; applyCharacter.finalAttack = finalValue; break; } case 2: //방어력 { var value = GetApplyValueType(skillData.applyValueType, applyCharacter.finalDefence, character); var finalValue = value * skillData.applyValue; applyCharacter.finalDefence = finalValue; break; } case 3: //충격량 { var dir = Vector3.Normalize( applyCharacter.transform.localPosition - occurStandardObj.characterTransform.localPosition); var value = GetApplyValueType(skillData.applyValueType, applyCharacter.ImpulseAddValue, character); var finalValue = value * skillData.applyValue; applyCharacter.ImpulsePercentValue = skillData.applyPercentValue; //적용될 오브젝트가 멈취있다면 if (applyCharacter.Physics.dir == Vector3.zero || applyCharacter.Physics.speed <= 0) { var speed = applyCharacter.Physics.GetQuadraticEquationValue(finalValue); applyCharacter.Physics.ApplyForce(dir, speed); Debug.Log(string.Format("준 충격량 : {0}\n방향 : {1} 속도 : {2}", finalValue, dir, speed)); } else { applyCharacter.ImpulseAddDir = dir; applyCharacter.ImpulseAddValue = applyCharacter.GetImpulseValue(finalValue); Debug.Log(string.Format("준 충격량 : {0}\n방향 : {1}", finalValue, dir)); } break; } case 4: //스킬 면역 횟수 { var finalValue = skillData.applyValue; //이미 무한인 경우 제외 if (applyCharacter.immuneCount != -1) { if (finalValue == -1) { applyCharacter.immuneCount = finalValue; } else { applyCharacter.immuneCount += finalValue; } } } break; case 5: //스킬 봉인 횟수 { var finalValue = skillData.applyValue; //이미 무한인 경우 제외 if (applyCharacter.lockCount != -1) { if (finalValue == -1) { applyCharacter.lockCount = finalValue; } else { applyCharacter.lockCount += finalValue; } } } break; case 6: //공격력 방어력 { var attackValue = GetApplyValueType(skillData.applyValueType, applyCharacter.finalAttack, character); var finalAttackValue = attackValue * skillData.applyValue; var defenceValue = GetApplyValueType(skillData.applyValueType, applyCharacter.finalDefence, character); var finalDefenceValue = defenceValue * skillData.applyValue; applyCharacter.finalAttack = finalAttackValue; applyCharacter.finalDefence = finalDefenceValue; } break; } CheckOneShot(skillData); }
public bool CheckSkill(SkillData skillData, CharacterPhysics otherObj) { //스킬이 없다면 false if (skillData.id == 0) { return(false); } //체크할 상대가 없다면 true if (otherObj == null) { return(true); } var otherCharacter = otherObj.character; //첫 충돌이 아니라면 if (!CheckFirstCollide(skillData)) { Debug.Log(string.Format("스킬 '{0}'\n발동 무시 {1} - 'CheckFirstCollide'에서 제외", skillData.desc, otherCharacter.name)); return(false); } //스킬이 발동되는 사이즈가 아니라면 if (!CheckSize(skillData, otherCharacter)) { Debug.Log(string.Format("스킬 '{0}'\n발동 무시 {1} - 'CheckSize'에서 제외", skillData.desc, otherCharacter.name)); return(false); } //상대의 공격력이 자신의 방어력을 넘겼다면 if (!CheckDefanceOver(skillData, otherCharacter)) { Debug.Log(string.Format("스킬 '{0}'\n발동 무시 {1} - 'CheckDefanceOver'에서 제외", skillData.desc, otherCharacter.name)); return(false); } //발동되는 팀 조건이 아니라면 if (!CheckObjectTeam(skillData, otherCharacter)) { Debug.Log(string.Format("스킬 '{0}'\n발동 무시 {1} - 'CheckObjectTeam'에서 제외", skillData.desc, otherCharacter.name)); return(false); } //자신에게 스킬 봉인 횟수가 남아 있다면 if (!CheckSkillLockCount()) { Debug.Log(string.Format("스킬 '{0} 발동 무시'\n{1} - 'lockCount'에서 제외 {2}의 남은 스킬 봉인 횟수 {3}", skillData.desc, otherCharacter.name, character.name, character.lockCount)); return(false); } //상대에게 스킬 면역 횟수가 남아 있다면 if (!CheckSkillImmuneCount(skillData, otherCharacter)) { Debug.Log(string.Format("스킬 '{0} 발동 무시'\n{1} - 'ImmuneCount'에서 제외 {2}의 남은 스킬 면역 횟수 {3}", skillData.desc, otherCharacter.name, otherCharacter.name, otherCharacter.immuneCount)); return(false); } return(true); }
void Start () { if (character == null) { character = transform.parent.GetComponent<CharacterPhysics>(); } }
public List <CharacterPhysics> GetApplyObject(SkillData skill, CharacterPhysics occurStandardObj, CharacterPhysics collisionObj, List <CharacterPhysics> physicsObjectList) { Debug.Log(string.Format("{0}의 스킬 발동 준비\n{1}", characterTransform.name, skill.desc)); switch (skill.applyObject) { case 0: //없음 Debug.Log(string.Format("applyObject : {0} (적용할 오브젝트 없음)", skill.applyObject)); break; case 1: //본인 Debug.Log(string.Format("applyObject : {0} (본인에게 적용)", skill.applyObject)); return(new List <CharacterPhysics>() { occurStandardObj }); case 2: //충돌된 대상 Debug.Log(string.Format("applyObject : {0} (충돌된 대상에게 적용)", skill.applyObject)); return(new List <CharacterPhysics>() { collisionObj }); case 3: //가장 가까운 아군 Debug.Log(string.Format("applyObject : {0} (가장 가까운 아군에게 적용)", skill.applyObject)); break; case 4: //가장 가까운 적군 Debug.Log(string.Format("applyObject : {0} (가장 가까운 적군에게 적용)", skill.applyObject)); break; case 5: //가장 가까운 아군/적군 { Debug.Log(string.Format("applyObject : {0} (가장 가까운 아군/적군에게 적용)", skill.applyObject)); var obj = GetNearCharacter(physicsObjectList); if (obj != null) { return(new List <CharacterPhysics>() { obj }); } break; } case 6: //범위 안 아군 Debug.Log(string.Format("applyObject : {0} (범위 안 아군에게 적용)", skill.applyObject)); break; case 7: //범위 안 적군 Debug.Log(string.Format("applyObject : {0} (범위 안 적군에게 적용)", skill.applyObject)); break; case 8: //범위 안 아군/적군 Debug.Log(string.Format("applyObject : {0} (범위 안 아군/적군에게 적용)", skill.applyObject)); return(GetCharacterInRange(skill.applyAngle, skill.applyRange, occurStandardObj, collisionObj, physicsObjectList)); case 9: //랜덤한 아군 Debug.Log(string.Format("applyObject : {0} (랜덤한 아군에게 적용)", skill.applyObject)); break; case 10: //랜덤한 적군 Debug.Log(string.Format("applyObject : {0} (랜덤한 적군에게 적용)", skill.applyObject)); break; case 11: //랜덤한 아군/적군 Debug.Log(string.Format("applyObject : {0} (랜덤한 아군/적군에게 적용)", skill.applyObject)); { var obj = GetRandomCharacter(physicsObjectList); if (obj != null) { return(new List <CharacterPhysics>() { obj }); } break; } case 12: //모든 대상 Debug.Log(string.Format("applyObject : {0} (모든 대상에게 적용)", skill.applyObject)); break; } return(null); }