/// <summary> /// Sets the initial position and the bot settings of the cubot /// </summary> /// <param name="initialPlotTile"></param> /// <param name="initialOrientation"></param> public void SetUp(LevelDescriptor configuration, List <PlotTile> tilesInScene) { this.tilesInScene = tilesInScene; CurrentOrientation = configuration.CharacterInitialOrientation; Vector3 cubotExtents = this.GetComponent <Renderer>().bounds.extents; Vector3Int cubotPlotInitialPosition = configuration.CharacterStartPointInPlot; PlotTile initialPlotTile = tilesInScene.Where(t => t.PlotPosition == cubotPlotInitialPosition).First(); float rotY = (int)CurrentOrientation; Vector3 initialPlotTileExtents = initialPlotTile.GetComponent <Renderer>().bounds.extents; //Cubot must be over an initial plot tile, so we are going to position it Vector3 initialPosition = initialPlotTile.transform.position; initialPosition.y += cubotExtents.y + initialPlotTileExtents.y; Vector3 cubotInitialRotation = new Vector3(0, rotY, 0); this.transform.position = initialPosition; this.transform.rotation = Quaternion.Euler(cubotInitialRotation); Speed = configuration.CharacterSpeed; CurrentTile = initialPlotTile; CurrentTile.Step(); }
// To do: Make references a <Dictionary<CharacterData.CharacterPart, SpriteRenderer>> void UpdateCharacter(CharacterOrientation orientation) { Head.sprite = visuals.SpriteSets[CharacterData.CharacterPart.Head].Get(orientation); Body.sprite = visuals.SpriteSets[CharacterData.CharacterPart.Body].Get(orientation); Hair.sprite = visuals.SpriteSets[CharacterData.CharacterPart.Hair].Get(orientation); Shirt.sprite = visuals.SpriteSets[CharacterData.CharacterPart.Top].Get(orientation); Pants.sprite = visuals.SpriteSets[CharacterData.CharacterPart.Bottom].Get(orientation); Hand_L.sprite = visuals.SpriteSets[CharacterData.CharacterPart.Hands].Get(orientation); Hand_R.sprite = visuals.SpriteSets[CharacterData.CharacterPart.Hands].Get(orientation); Face.sprite = visuals.SpriteSets[CharacterPart.Face].Get(orientation); }
void UpdateCharacterOrientationInternal(CharacterOrientation orientation) { if ((int)orientation == (int)_currentCharacterOrientation) { return; } foreach (var key in References.Keys) { References[key].sprite = visuals.SpriteSets[key].Get(orientation); } var handSprite = visuals.SpriteSets[CharacterPart.Hands].Get(orientation); Hand_L.sprite = handSprite; Hand_R.sprite = handSprite; _currentCharacterOrientation = orientation; }
public void UpdateCharacterOrientation(CharacterOrientation orientation) { if (orientation == CharacterOrientation.Bot) { FaceDOWN(); } else if (orientation == CharacterOrientation.Top) { FaceUP(); } else if (orientation == CharacterOrientation.Right) { FaceRIGHT(); } else if (orientation == CharacterOrientation.Left) { FaceLEFT(); } }
public Sprite Get(CharacterOrientation orientation) { switch (orientation) { case CharacterOrientation.Bot: return(Bot); case CharacterOrientation.Top: return(Top); case CharacterOrientation.Right: return(Right); case CharacterOrientation.Left: return(Left); } // Just so compiler compiles return(null); }
public void UpdateVisuals(CharacterOrientation orientation) { if (previousOrientation == (int)orientation) { return; } previousOrientation = (int)orientation; foreach (var key in bodyKeys) { var _key = (int)key; var part = _bodyParts[_key]; var set = SpriteSets[_key]; part.sprite = set.Get(orientation); } var handSpr = SpriteSets[(int)CharacterPart.Hands].Get(orientation); Hand_L.sprite = handSpr; Hand_R.sprite = handSpr; }
public void AcceptAttributeCharacterOrientation(CharacterOrientation characterOrientation, PrintContext parameter) { parameter.WriteLine("Character Orientation: up {0}, base {1}", characterOrientation.Up, characterOrientation.Base); }
public virtual void AcceptAttributeCharacterOrientation(CharacterOrientation characterOrientation, T parameter) { // intentionally left blank }
///<summary> /// Constructs a new player. ///</summary> public GameCharacter(Texture2D texture, Vector2 position, SpriteBatch spritebatch, int fighterNumber, int meleeDamage, int rangedDamage, ContentManager contenter, Texture2D projectoSprite /*, Texture2D meleoSprite*/) : base(texture, position, spritebatch) { Rate = 0; Philo = 0; Money = 0; playerSprite = texture; projectileSprite = projectoSprite; //meleeSprite = meleoSprite; life = true; fighterTag = fighterNumber; meleeAttack = meleeDamage; rangedAttack = rangedDamage; this.fighterNumber = fighterNumber; source = new Rectangle(0, 0, playerSprite.Width, playerSprite.Height); playerDimensions.X = source.Width; playerDimensions.Y = source.Height; _theContenter = contenter; LoadContent(); if (this.fighterNumber == 1) { upkey = Keys.W; leftkey = Keys.A; rightkey = Keys.D; downkey = Keys.S; attackM = Keys.F; attackR = Keys.G; _characterOrientation = CharacterOrientation.right; _characterState = CharacterState.onGround; //health = 100; } else if (this.fighterNumber == 2) { upkey = Keys.Up; leftkey = Keys.Left; rightkey = Keys.Right; downkey = Keys.Down; attackM = Keys.O; attackR = Keys.P; _characterOrientation = CharacterOrientation.left; _characterState = CharacterState.onGround; //health = 100; } else if (this.fighterNumber == 3) { upkey = Keys.H; leftkey = Keys.B; rightkey = Keys.M; downkey = Keys.N; attackM = Keys.RightAlt; attackR = Keys.RightControl; _characterOrientation = CharacterOrientation.right; _characterState = CharacterState.onGround; //health = 100; } else if (this.fighterNumber == 4) { upkey = Keys.NumPad8; leftkey = Keys.NumPad4; rightkey = Keys.NumPad6; downkey = Keys.NumPad5; attackM = Keys.Multiply; attackR = Keys.Subtract; _characterOrientation = CharacterOrientation.left; _characterState = CharacterState.onGround; //health = 100; } }
//enumerations public void setCharacterOrientation(CharacterOrientation whereYouLook) { _characterOrientation = whereYouLook; }
// Update is called once per frame void Update() { print("Checking for movement"); try { float speed = Speed; if (destination.movementPhases != null && destination.movementPhases.Count > 0) { MovementType nextMove = destination.movementPhases[0]; if (nextMove == MovementType.NONE) { print("No movement"); // destinyTile is not null, when other actions were executed before // so at this point, bot is at another tile if (destination.destinyTile != null) { CurrentTile = destination.destinyTile; CurrentTile.Step(); // Marks the tile as stepped } ResetMovement(); } else { if (nextMove == MovementType.ROTATE) { destination.initialYRotation = destination.initialYRotation.HasValue ? destination.initialYRotation.Value : transform.rotation.eulerAngles.y; ExecutingAction = true; float step = Time.deltaTime * speed; float destinyYRotation = destination.initialYRotation.Value + (int)destination.rotOrientation * ROTATION_AMOUNT; Vector3 destinyRotation = transform.rotation.eulerAngles; destinyRotation.y = destinyYRotation; Quaternion destinyQuat = Quaternion.Euler(destinyRotation); transform.rotation = Quaternion.RotateTowards(transform.rotation, destinyQuat, step); float angle = Quaternion.Angle(transform.rotation, destinyQuat); if (Mathf.Abs(angle) < 0.01f) { destination.movementPhases.RemoveAt(0); this.CurrentOrientation = destination.characterDestinyOrientation; } } else { print("Going to move"); ExecutingAction = true; Vector3 tileExtents = destination.destinyTile.GetComponent <Renderer>().bounds.extents; Vector3 cubotExtents = this.GetComponent <Renderer>().bounds.extents; Vector3 destinyPosition = new Vector3(); switch (nextMove) { case MovementType.FORWARD: destinyPosition = destination.destinyTile.transform.position; destinyPosition.y = this.transform.position.y; //We are moving the character over a Tile, and not to the center of the tile break; case MovementType.CLIMB_UP: //Climb up phase consist only in elevating the character. It is supposed to call a forward after this case MovementType.CLIMB_DOWN: //Climb down phase consist only in landing the character. It is supposed to have a forward call before destinyPosition = this.transform.position; destinyPosition.y = destination.destinyTile.transform.position.y + tileExtents.y + cubotExtents.y; break; } float step = speed * Time.deltaTime; // calculate distance to move transform.position = Vector3.MoveTowards(transform.position, destinyPosition, step); if (Vector3.Distance(transform.position, destinyPosition) < 0.1f) { destination.movementPhases.RemoveAt(0); } } } } } catch (Exception ex) { ResetMovement(); throw ex; } }