public override void Initialize(LDBlock data) { bool found = false; LDCharacter OwningCharacter = new LDCharacter(); foreach (LDCharacter Character in data.characters) { if (Character.role == (byte)Role) { OwningCharacter = Character; found = true; } } if(!found) { DestroyImmediate(gameObject); return; } GridPos = (Vector2Int)GameStateManager.Instance.GetGridManager().WorldToCell(transform.position); transform.position = GameStateManager.Instance.GetGridManager().CellToWorld((Vector3Int)GridPos); GameStateManager.Instance.GetGridManager().setOccupied((Vector3Int)GridPos, true); Animator = GetComponentInChildren<Animator>(); AbilitySystem = new AbilitySystem(this); Name = OwningCharacter.name; Color = (CharacterColor)OwningCharacter.color; if (OwningCharacter.timeLine != null) { TimeLine = OwningCharacter.timeLine.ToList(); } else { TimeLine = new List<LDInputFrame>(); } CharacterDataTemplate Data = CharacterDataTemplate.Load(); if (OwningCharacter.attributes == null || OwningCharacter.attributes.Length == 0) { // NOTE: First time, Playing from start! Data.GetStartingAttributes(Role) .ForEach(Entry => AbilitySystem.RegisterAttribute(Entry.Attribute, Entry.Value)); } else { AbilitySystem.RegisterLDAttributes(OwningCharacter.attributes); } Data.GetAbilities(Role) .ForEach(Ability => AbilitySystem.GrantAbility(Ability)); Data.GetStartingEffects(Role) .ForEach(Effect => AbilitySystem.TryApplyEffectToSelf(Effect)); AbilitySystem.RegisterOnAttributeChanged(Attribute.Health, OnDamageTaken); CurrentHealth = AbilitySystem.GetAttributeValue(Attribute.Health).Value; AbilitySystem.RegisterOnAttributeChanged(Attribute.MaxHealth, UpdateMaxHealth); MaxHealth = AbilitySystem.GetAttributeValue(Attribute.MaxHealth).Value; }
public static Color ToColor(this CharacterColor color) { switch (color) { default: case CharacterColor.White: return(Color.white); case CharacterColor.Black: return(Color.black); case CharacterColor.Yellow: return(Color.yellow); case CharacterColor.Blue: return(Color.blue); case CharacterColor.Green: return(Color.green); case CharacterColor.Red: return(Color.red); case CharacterColor.Purple: return(new Color32(128, 0, 128, 255)); case CharacterColor.Pink: return(Color.magenta); } }
private void OnCollisionEnter2D(Collision2D collision) { if (CharacterColor.CompareColor(_sprite.color, collision.transform.Find("Body").GetComponent <SpriteRenderer>().color)) { Physics2D.IgnoreCollision(collision.transform.GetComponent <BoxCollider2D>(), transform.GetComponent <BoxCollider2D>()); } }
public void SetColor(CharacterColor characterColor) { hair = characterColor.hair; eyes = characterColor.eyes; skin = characterColor.skin; torso = characterColor.torso; arms = characterColor.arms; legs = characterColor.legs; foots = characterColor.foots; }
private void SetCharacterColor(CharacterColor characterColor) { _characterColor = characterColor; Material mat = Resources.Load <Material>("Materials/" + _characterColor.ToString()); foreach (var renderer in _body.GetComponentsInChildren <Renderer>()) { renderer.material = mat; } }
void SetMaterial(int color) { _color = (CharacterColor)color; Material[] aux = skinnedMesh.materials; aux[1] = materials[color]; skinnedMesh.materials = aux; if (networkView.isMine) { networkView.RPC("SetMaterial", RPCMode.Others, (int)_color); } }
private void SetCharacterColor(Transform bodyTran, string colorName, bool isSendRPC = true) { Transform charaBoxTran = bodyTran.FindChild(Common.CO.PARTS_MAIN_BODY); if (charaBoxTran != null) { CharacterColor charaColor = charaBoxTran.GetComponentInChildren <CharacterColor>(); if (charaColor != null) { charaColor.SetColor(colorName); } } }
// Update is called once per frame void Update() { if (playerCharacteristics != null && playerCharacteristics.color != color) { color = playerCharacteristics.color; SetSelectedCharacterAnimator(color); UpdateAnimator(); } if (m_health != null && actualDamageLevel != m_health.DamageLevel) { actualDamageLevel = m_health.DamageLevel; UpdateAnimator(); } }
private static string GetOwnedAddress(int level, CharacterColor color) { switch (level) { case 0: return($"Assets/Tileset/property-owned-{color.ToString().ToLower()}.asset"); case 1: // fall through case 2: return($"Assets/Tileset/property-level-{level + 1}-{color.ToString().ToLower()}.asset"); } return(DEFAULT_ADDRESS); // use as error asset for now }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player") && CharacterColor.CompareColor(collision.transform.Find("Body").GetComponent <SpriteRenderer>().color, neededColor.GetColor(_colorIndex))) { controller.currentColors.RemoveColor(neededColor.GetColor(_colorIndex)); controller.playersInGame.Remove(collision.gameObject); //controller.characterIndex = 0; controller.SetActiveCharacter(0); Destroy(collision.gameObject); _colorIndex++; onDeliverColor.Invoke(this, new onDeliverColorEventArgs { index = _colorIndex }); } }
void Awake() { if (_instance == null) { _instance = this; for (int i = 0; i < characterList.Count; i++) { for (int j = 0; j < characterList[i].assicIds.Count; j++) { colorDic.Add(characterList[i].assicIds[j], characterList[i]); } } } }
void SendColor(int color) { _color = (CharacterColor)color; Debug.Log("Got color " + _color); if (Network.isClient) { if (networkView.isMine) { Debug.Log("Set lobbymanager color"); clientManager.lobbyManager.SetColor(_color.ToColor()); clientManager.playerColor = _color; } else { Debug.Log("Show color"); if (lobbyCharacterView != null) { lobbyCharacterView.color = _color.ToColor(); } } } }
public void SetColor(CharacterColor characterColor) { if (isSprite) { hair.GetComponent <SpriteRenderer>().color = characterColor.hair; eyes.GetComponent <SpriteRenderer>().color = characterColor.eyes; skin.GetComponent <SpriteRenderer>().color = characterColor.skin; torso.GetComponent <SpriteRenderer>().color = characterColor.torso; arms.GetComponent <SpriteRenderer>().color = characterColor.arms; legs.GetComponent <SpriteRenderer>().color = characterColor.legs; foots.GetComponent <SpriteRenderer>().color = characterColor.foots; } else { hair.GetComponent <Image>().color = characterColor.hair; eyes.GetComponent <Image>().color = characterColor.eyes; skin.GetComponent <Image>().color = characterColor.skin; torso.GetComponent <Image>().color = characterColor.torso; arms.GetComponent <Image>().color = characterColor.arms; legs.GetComponent <Image>().color = characterColor.legs; foots.GetComponent <Image>().color = characterColor.foots; } }
private void CreateNpcBody() { //メインボディ名取得 string npcName = charaInfo[Common.Character.DETAIL_PREFAB_NAME_NO]; //メインボディ生成 GameObject charaMainObj = PhotonNetwork.Instantiate(Common.Func.GetResourceCharacter(npcName), Vector3.zero, Quaternion.identity, 0); charaMainObj.name = Common.CO.PARTS_BODY; Transform charaMainTran = charaMainObj.transform; //カラー設定 CharacterColor charaColor = charaMainTran.GetComponentInChildren <CharacterColor>(); if (charaColor != null) { charaColor.SetColor(charaInfo[Common.Character.DETAIL_COLOR_NO]); } //メインボディ紐付け charaMainTran.SetParent(myTran, false); charaMainTran.localPosition = Vector3.zero; charaMainTran.rotation = myTran.rotation; }
void SetSelectedCharacterAnimator(CharacterColor color) { selectedCharacterAnimator = characterAnimators.Where(c => c.characterColor == color).FirstOrDefault(); }
public MapleCharacter(CharacterColor c, int face, int hair, GraphicsDevice graphics) { try { SkinColor = c; WZFile charWz = new WZFile("Character.wz", WZVariant.GMS, true, WZReadSelection.LowMemory); string path = ((int)SkinColor).ToString("00000000") + ".img"; WZCanvasProperty h = (WZCanvasProperty)charWz.ResolvePath(((int)SkinColor).ToString("00010000") + ".img/front/head"); WZPointProperty o = (WZPointProperty)h["origin"]; Head = new MapleCanvas(Tools.BitmapToTexture(graphics, h.Value), new Vector2(-o.Value.X, -o.Value.Y)); Bounds.X = -o.Value.X; Bounds.Y = -o.Value.Y; WZPointProperty neckPos = (WZPointProperty)h["map"]["neck"]; NeckPosition = new Vector2(neckPos.Value.X, neckPos.Value.Y); foreach (CharacterState state in Enum.GetValues(typeof(CharacterState))) // Loop through the states and get the frames for each animation.. { Dictionary<int, MapleFrame> bodyState = new Dictionary<int, MapleFrame>(); Dictionary<int, MapleFrame> armState = new Dictionary<int, MapleFrame>(); foreach (WZObject frame in charWz.ResolvePath(path + "/" + States[(int)state])) if (Tools.IsNumeric(frame.Name)) { int delay = frame["delay"].ValueOrDefault<int>(250); Vector2 bodyNavel = Vector2.Zero; Vector2 frameNeckPos = Vector2.Zero; bool ani = Ani[(int)state]; foreach (WZObject part in frame) { WZObject p = part; if (p is WZCanvasProperty) { Texture2D PartTexture = Tools.BitmapToTexture(graphics, p.ValueOrDie<System.Drawing.Bitmap>()); WZPointProperty origin = (WZPointProperty)p["origin"]; switch (p.Name) { case "body": WZPointProperty navel = (WZPointProperty)p["map"]["navel"]; WZPointProperty neck = (WZPointProperty)p["map"]["neck"]; Navel.Add(States[(int)state] + frame.Name, new Vector2(-navel.Value.X, -navel.Value.Y)); bodyNavel = new Vector2(navel.Value.X, navel.Value.Y); frameNeckPos = new Vector2(-neck.Value.X, -neck.Value.Y); Vector2 BodyLoc = new Vector2(-origin.Value.X + frameNeckPos.X + NeckPosition.X, -origin.Value.Y + frameNeckPos.Y + NeckPosition.Y); bodyState.Add(bodyState.Count, new MapleFrame(new MapleCanvas(PartTexture, BodyLoc), delay)); break; case "arm": WZPointProperty armNavel = (WZPointProperty)p["map"]["navel"]; Vector2 ArmLoc = new Vector2((-origin.Value.X + -armNavel.Value.X - -bodyNavel.X) + frameNeckPos.X + NeckPosition.X, (-origin.Value.Y + -armNavel.Value.Y - -bodyNavel.Y) + frameNeckPos.Y + NeckPosition.Y); armState.Add(armState.Count, new MapleFrame(new MapleCanvas(PartTexture, ArmLoc), delay)); break; } } } if (ani == false) break; } Body.Add(state, new MapleAnimation(bodyState, true)); Arm.Add(state, new MapleAnimation(armState)); if (Hair.ContainsKey(HairStates[(int)state])) continue; // Hair string hairPath = "Hair/" + hair.ToString("00000000") + ".img"; Dictionary<int, MapleFrame> hf = new Dictionary<int, MapleFrame>(); Dictionary<int, MapleFrame> hfh = new Dictionary<int, MapleFrame>(); WZCanvasProperty hairCanvas = (WZCanvasProperty)charWz.ResolvePath(hairPath + "/" + HairStates[(int)state] + "/hairOverHead"); WZPointProperty hairOrigin = (WZPointProperty)hairCanvas["origin"]; WZCanvasProperty hhatCanvas = (WZCanvasProperty)charWz.ResolvePath(hairPath + "/" + HairStates[(int)state] + "/hair"); WZPointProperty hhatOrigin = (WZPointProperty)hhatCanvas["origin"]; hf.Add(hf.Count, new MapleFrame(new MapleCanvas(Tools.BitmapToTexture(graphics, hairCanvas.Value), new Vector2(-hairOrigin.Value.X - 2, -hairOrigin.Value.Y - 5)), 100)); hfh.Add(hfh.Count, new MapleFrame(new MapleCanvas(Tools.BitmapToTexture(graphics, hhatCanvas.Value), new Vector2(-hhatOrigin.Value.X - 2, -hhatOrigin.Value.Y - 5)), 100)); Hair.Add(HairStates[(int)state], new MapleAnimation(hf)); HatHair.Add(HairStates[(int)state], new MapleAnimation(hfh)); } // Face string facePath = "Face/" + face.ToString("00000000") + ".img"; Dictionary<int, MapleFrame> ff = new Dictionary<int, MapleFrame>(); foreach (WZObject fs in charWz.ResolvePath(facePath + "/default")) // TODO Other expressions { if (fs is WZCanvasProperty && fs.Name == "face") { WZPointProperty faceOrigin = (WZPointProperty)fs["origin"]; ff.Add(ff.Count, new MapleFrame(new MapleCanvas(Tools.BitmapToTexture(graphics, fs.ValueOrDie<System.Drawing.Bitmap>()), new Vector2(-faceOrigin.Value.X - 3, -faceOrigin.Value.Y + 7)), 0)); } } Face = new MapleAnimation(ff); } catch (Exception ex) { MapleConsole.Write(MapleConsole.LogType.ERROR, "Error initializing character: " + ex.Message); MapleConsole.Write(MapleConsole.LogType.WARNING, "StackTrace", ex.StackTrace); } }