public PlayerControler(ConnectedHost host,WorldControler world) { mHost = host; mWorld = world; mPathFinder = new Pathfinder(); PlayerBaseInformations = new PlayerBaseInformationsModel(mHost); PlayerCharacteristics = new PlayerCharacteristicsModel(mHost); PlayerInventory = new PlayerInventoryModel(mHost); PlayerSpells = new PlayerSpellsModel(mHost); PlayerJobs = new PlayerJobsModel(mHost); mMoveFrame = new MoveFrame(mHost); PlayerFightInformations = new PlayerFightInformationsModel(mHost); }
public void AddMove(float time, Transform trans, Vector2 velocity, string action) { // set end marker of last item to false if more than one item in List int i = frames.Count - 1; if (i > 0) { MoveFrame temp = frames [i]; frames [i] = new MoveFrame(temp.deltaTime, temp.trans, temp.vel, temp.action, false); t = t + frames [frames.Count - 1].deltaTime; } frames.Add(new MoveFrame(time, trans, velocity, action)); // add new item // only keep enough frames to replay total time in history if (HistoryFull()) { frames.RemoveAt(0); } Debug.Log(string.Format("Items:{0} Time:{1}", frames.Count, t)); }
public MoveFrame GetFrame(int i) { MoveFrame ret = i < frames.Count ? frames [i] : frames [frames.Count - 1]; return(ret); }
//checks what to do at the start of each frame in an attack animation public void RunAttackFrame(PlayerController user, Attack attack, int frame) { MoveFrame attackFrame = attack.frameData[frame]; user.canGrabLedge = attackFrame.ledgeGrab; //runs on frames that play audio if (attackFrame.playSound && user.moveState != PlayerController.MoveStates.HITLAG) { user.PlaySound(attackFrame.frameSound); } //B-reversing in the first few frames of a move if (attack.special && attack.reversable && frame < attack.reverseFrames) { if (user.isFacingLeft) { if (user.hori >= user.horiThreshold) { user.isFacingLeft = false; user.airMomentum.x *= -1; } } else { if (user.hori <= -user.horiThreshold) { user.isFacingLeft = true; user.airMomentum.x *= -1; } } } //Sets user's transparency //later //user.render.material = GameLoader.SetAlpha(user.render.material, attackFrame.frameAlpha); //moves the user by the frames specified vector, if any if ((attackFrame.userMovement != Vector3.zero || attackFrame.userMomentum != Vector3.zero || attackFrame.userTranslation != Vector3.zero) && user.moveState != PlayerController.MoveStates.HITLAG) { Vector3 tempMovement; Vector3 tempMomentum; Vector3 tempTranslation; if (user.isFacingLeft) { tempMovement = attackFrame.userMovement; tempMomentum = attackFrame.userMomentum; tempTranslation = attackFrame.userTranslation; } else { tempMovement = new Vector3(-attackFrame.userMovement.x, attackFrame.userMovement.y); tempMomentum = new Vector3(-attackFrame.userMomentum.x, attackFrame.userMomentum.y); tempTranslation = new Vector3(-attackFrame.userTranslation.x, attackFrame.userTranslation.y); } if (user.topColl) { tempMovement.y = GameData.ClampFloat(tempMovement.y, true); tempMomentum.y = GameData.ClampFloat(tempMomentum.y, true); tempTranslation.y = GameData.ClampFloat(tempTranslation.y, true); } if (user.leftColl) { tempMovement.x = GameData.ClampFloat(tempMovement.x); tempMomentum.x = GameData.ClampFloat(tempMomentum.x); tempTranslation.x = GameData.ClampFloat(tempTranslation.x); } if (user.rightColl) { tempMovement.x = GameData.ClampFloat(tempMovement.x, true); tempMomentum.x = GameData.ClampFloat(tempMomentum.x, true); tempTranslation.x = GameData.ClampFloat(tempTranslation.x, true); } if (user.isGrounded) { if (attackFrame.setMomentum) { user.groundMomentum = tempMovement; } user.groundMomentum += tempMomentum; } else { if (attackFrame.setMomentum) { user.airMomentum = tempMovement; } user.airMomentum += tempMomentum; } user.transform.position += tempTranslation; } //allows for multihit moves. Always put rehit on an inactive frame if (attackFrame.reHit && user.moveState != PlayerController.MoveStates.HITLAG) { foreach (List <Attack> nullify in nullAttackLists) { nullify.Remove(attack); } } //runs on i-frames if (attackFrame.iFrame) { user.MakeInvincible(false); } else { user.MakeInvincible(true); } //runs on frames with no active hitboxes if (attackFrame.startupFrame == true || attackFrame.endlagFrame == true) { if (!allHitboxesDisabled) { foreach (GameObject hitbox in currHitboxes) { hitbox.GetComponent <SphereCollider>().enabled = false; } allHitboxesDisabled = true; } } //runs on frames that spawn projectiles if (attackFrame.spawnProjectile && user.moveState != PlayerController.MoveStates.HITLAG) { attack.projectile.GetComponent <HitBox>().user = user; Projectile proj = attack.projectile.GetComponent <Projectile>(); proj.user = user; foreach (GameObject go in attack.hitBoxes) { go.GetComponent <HitBox>().user = user; } if (!user.isFacingLeft) { Instantiate(attack.projectile, user.transform.position + proj.offset, proj.rotation); } else { Instantiate(attack.projectile, user.transform.position + new Vector3(-proj.offset.x, proj.offset.y), new Quaternion(proj.rotation.x, proj.rotation.y + 180, proj.rotation.z, 0)); } } //runs on frames that contain active hitboxes if (attackFrame.hitboxActive == true) { allHitboxesDisabled = false; //Animates animated hitboxes if (attackFrame.hitboxAnimated) { int i = 0; foreach (Vector3 offset in attackFrame.allHitboxesAnimated) { if (offset.x != 0 || offset.y != 0) { currHitboxes[i].transform.Translate(new Vector3(offset.x, offset.y)); } i++; } } //Disables/enables hitboxes as described in allHitboxesActive for (int i2 = 0; i2 < attackFrame.allHitboxesActive.Count; i2++) { if (attackFrame.allHitboxesActive[i2]) { currHitboxes[i2].GetComponent <SphereCollider>().enabled = true; } else { currHitboxes[i2].GetComponent <SphereCollider>().enabled = false; } } } else //runs on the last frame of an attack if (attackFrame.lastFrame == true) { user.EndAttack(); } }