Пример #1
0
        public ActionResult Create(CharactersModel characterModel, List <Character_Details> detailsList)
        {
            var player_id = Convert.ToInt32(TempData["Player_id"]);

            if (ModelState.IsValid)
            {
                characterModel.Character.Parent_id = player_id;
                Log.WriteLog("Creazione del character per il player: " + player_id.ToString(), 2);
                db.Characters.Add(characterModel.Character);
                db.SaveChanges();
                Log.WriteLog("New character salvato", 2);

                foreach (var item in detailsList)
                {
                    item.Character_id = characterModel.Character.System_id;
                    if (item.Section != "Deleted")
                    {
                        db.Character_Details.Add(item);
                        db.SaveChanges();
                        Log.WriteLog(string.Format("Salvato il dettagli {0} per il character {1}", item.Name, player_id.ToString()), 2);
                    }
                }
                characterModel.SetMaxBloodPool();
                Log.WriteLog(string.Format("Settato il MaxBloodPool per il character: {0}", characterModel.Character.Name), 2);
                return(RedirectToAction("Index", new { id = TempData["Player_id"] }));
            }

            ViewBag.Clans       = Clans;
            ViewBag.Generations = Generations;
            ViewBag.Story_id    = new SelectList(db.Stories, "System_id", "Name");
            ViewBag.Player_id   = db.Players.SingleOrDefault(p => p.System_Id == player_id);
            ViewBag.Story_id    = new SelectList(db.Stories, "System_id", "Name");
            return(View(characterModel.Character));
        }
 public CharactersPage()
 {
     InitializeComponent();
     charactersModel = CharactersModel.Instance;
     CharacterNamesCB.ItemsSource = charactersModel.Characters;
     CharacterNamesCB.SelectedIndex = 0;
 }
Пример #3
0
        // GET: Characters/Edit/5
        public ActionResult Edit(int id)
        {
            CharactersModel model = new CharactersModel(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Clans       = Clans;
            ViewBag.Generations = Generations;
            ViewBag.Disciplines = Disciplines;
            ViewBag.Backgrounds = Backgrounds;
            ViewBag.Story_id    = new SelectList(db.Players.Find(model.Character.Parent_id).Stories, "System_id", "Name");
            UpdateRecentItems(model.Character);
            return(View(model));
        }
Пример #4
0
        // GET: Characters/Create
        public ActionResult Create(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ViewBag.Clans       = Clans;
            ViewBag.Generations = Generations;
            ViewBag.Player_id   = id;
            ViewBag.Story_id    = new SelectList(db.Players.Find(id).Stories, "System_id", "Name");
            var model = new CharactersModel();

            model.Character.Player    = db.Players.Find(id);
            model.Character.Parent_id = Convert.ToInt32(id);
            return(View(model));
        }
Пример #5
0
    public override void Init()
    {
        _currentHeroes = new CharactersModel(DataHolder._data.LoadCharacters());
        ExperienceByLevel.Clear();
        for (var i = 1; i < LevelNum; i++)
        {
            var value = i;
            ExperienceByLevel.Add(i, BaseExp + value * value + (int)(Math.Pow(value, 1 + ExpChange * value)));
        }

        SkillExperienceByLevel.Clear();
        for (var i = 1; i < SkillLevelNum; i++)
        {
            var value = i;
            SkillExperienceByLevel.Add(i, SkillBaseExp + value * value + (int)(Math.Pow(value, 1 + SkillExpChange * value)));
        }
    }
Пример #6
0
        public ActionResult Edit(CharactersModel model, List <Character_Details> detailsList)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.Entry(model.Character).State = EntityState.Modified;
                    db.SaveChanges();
                    Log.WriteLog("Salvate le modifiche generali per il personaggio: " + model.Character.Name, 2);

                    for (int i = 0; i < detailsList.Count; i++)
                    {
                        if (detailsList[i].System_id != 0)
                        {
                            Log.WriteLog(string.Format("Salvataggio delle modfiche del dettaglio {0} per il character {1}",
                                                       detailsList[i].Name, detailsList[i].Character_id.ToString()), 2);
                            db.Entry(detailsList[i]).State = EntityState.Modified;
                        }
                        else
                        {
                            Log.WriteLog(string.Format("Inserimento del nuovo dettaglio {0} per il personaggio {1}",
                                                       detailsList[i].Name, model.Character.System_id), 2);
                            detailsList[i].Character_id = model.Character.System_id;
                            db.Character_Details.Add(detailsList[i]);
                        }
                    }
                    db.SaveChanges();
                    Log.WriteLog("Modifiche ai dettagli effettuate", 2);
                    model.SetMaxBloodPool();
                    Log.WriteLog(string.Format("Settato il MaxBloodPool per il character: {0}", model.Character.Name), 2);
                }
                catch (Exception ex)
                {
                    Log.WriteLog(string.Format("Errore nel salvatagio delle modifiche per il personaggio {0}: {1}",
                                               model.Character.System_id, ex.Message), 1);
                }
                return(RedirectToAction("Edit", new { id = model.Character.System_id }));
            }
            ViewBag.Clans       = Clans;
            ViewBag.Generations = Generations;
            ViewBag.Disciplines = Disciplines;
            ViewBag.Backgrounds = Backgrounds;
            ViewBag.Story_id    = new SelectList(db.Stories, "System_id", "Name");
            return(View(model));
        }
Пример #7
0
    public void OnModelChanged(CharactersModel model)
    {
        charInfoController.RefreshHeroesModel(model);

        var hero = _currentHero != null?model.Characters.FirstOrDefault(c => c.id == _currentHero.id) : null;

        if (hero == null)
        {
            if (model.Characters.Length > 0)
            {
                hero = model.Characters[0];
            }
            else
            {
                ViewUtility.HideThenShow <CharactersView, CharacterOverviewView>();
                return;
            }
        }
        OnHeroChanged(hero);
    }
Пример #8
0
        // GET: Characters/Details/5
        public ActionResult Details(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CharactersModel model = new CharactersModel(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Clans       = Clans;
            ViewBag.Generations = Generations;
            ViewBag.Disciplines = Disciplines;
            ViewBag.Backgrounds = Backgrounds;
            ViewBag.Story_id    = new SelectList(db.Stories, "System_id", "Name");
            UpdateRecentItems(model.Character);
            return(View(model));
        }
 public void OnModelChanged(CharactersModel model)
 {
     _heroesModel = model;
     MakeCharacterIcons();
 }
Пример #10
0
    public string GameLogic(string IDCLiente = null, string _Turn = null)
    {
        if (CURRENT_STATE == GameState.ON)
        {
            if (P1.IDCliente == IDCLiente && !P1.TurnSend)
            {
                ListToSend = new SimpleJSON.JSONArray();
                //ListToSend = new List<string>();

                var p_JsonResponseArray = JSONArray.Parse(_Turn).AsArray;
                for (int i = 0; i < p_JsonResponseArray.Count; i++)
                {
                    CharactersModel _char_response = new CharactersModel();

                    JSONNode _responseJSON = JSONNode.Parse(p_JsonResponseArray[i]);

                    int id_Character = _responseJSON["id"].AsInt;

                    _char_response.CurrentTile = _responseJSON["CurrentTile"].Value;
                    Console.WriteLine(_char_response.CurrentTile);

                    int CurrentHP_Character = _responseJSON["CurrentHP"].AsInt;
                    int CurrentAP_Character = _responseJSON["CurrentAP"].AsInt;

                    if (id_Character == P1.MeeleId)
                    {
                        if (P1.MeeleCurrentAP != CurrentAP_Character || P1.MeeleCurrentHP != CurrentHP_Character)
                        {
                            //"cheating?";
                        }
                    }
                    else if (id_Character == P1.ArcherId)
                    {
                        if (P1.ArcherCurrentAP != CurrentAP_Character || P1.ArcherCurrentHP != CurrentHP_Character)
                        {
                            //"cheating?";
                        }
                    }
                    else if (id_Character == P1.MageId)
                    {
                        if (P1.MageCurrentAP != CurrentAP_Character || P1.MageCurrentHP != CurrentHP_Character)
                        {
                            //"cheating?";
                        }
                    }

                    //List<string> WalkedTiles_Character = _responseJSON["WalkedTiles"].Value;
                    //List<string> ActionTilesAtk_Character = _responseJSON["ActionTilesAtk"].Value;
                    //List<string> ActionTilesDef_Character = _responseJSON["ActionTilesDef"].Value;
                    var walk = _responseJSON["WalkedTiles"];
                    for (int w_index = 0; w_index < walk.Count; w_index++)
                    {
                        _char_response.WalkedTiles.Add(walk[w_index]);
                        _char_response.CurrentTile = walk[w_index];
                    }

                    var actionAtk = _responseJSON["ActionTilesAtk"];
                    for (int aa_index = 0; aa_index < actionAtk.Count; aa_index++)
                    {
                        _char_response.ActionTilesAtk.Add(actionAtk[aa_index]);
                    }

                    var actionDef = _responseJSON["ActionTilesDef"];
                    for (int ad_index = 0; ad_index < actionDef.Count; ad_index++)
                    {
                        _char_response.ActionTilesDef.Add(actionDef[ad_index]);
                    }

                    _char_response.id        = id_Character;
                    _char_response.CurrentHP = CurrentHP_Character;
                    _char_response.CurrentAP = 10;



                    _ResponseP1.Add(_char_response);
                }
                P1.TurnSend = true;
                // CURRENT_STATE = GameState.REQUEST_TURN;
                return("Dados do Turno recebidos");
            }
            if (P2.IDCliente == IDCLiente && !P2.TurnSend)
            {
                ListToSend = new SimpleJSON.JSONArray();
                //ListToSend = new List<string>();

                var p_JsonResponseArray = JSONArray.Parse(_Turn).AsArray;
                for (int i = 0; i < p_JsonResponseArray.Count; i++)
                {
                    CharactersModel _char_response = new CharactersModel();

                    JSONClass rootNode = new JSONClass();

                    JSONNode _responseJSON = JSONNode.Parse(p_JsonResponseArray[i]);

                    int id_Character = _responseJSON["id"].AsInt;

                    _char_response.CurrentTile = _responseJSON["CurrentTile"].Value;
                    Console.WriteLine(_char_response.CurrentTile);

                    int CurrentHP_Character = _responseJSON["CurrentHP"].AsInt;
                    int CurrentAP_Character = _responseJSON["CurrentAP"].AsInt;

                    if (id_Character == P2.MeeleId)
                    {
                        if (P2.MeeleCurrentAP != CurrentAP_Character || P2.MeeleCurrentHP != CurrentHP_Character)
                        {
                            //"cheating?";
                        }
                    }
                    else if (id_Character == P2.ArcherId)
                    {
                        if (P2.ArcherCurrentAP != CurrentAP_Character || P2.ArcherCurrentHP != CurrentHP_Character)
                        {
                            //"cheating?";
                        }
                    }
                    else if (id_Character == P2.MageId)
                    {
                        if (P2.MageCurrentAP != CurrentAP_Character || P2.MageCurrentHP != CurrentHP_Character)
                        {
                            //"cheating?";
                        }
                    }

                    //List<string> WalkedTiles_Character = _responseJSON["WalkedTiles"].Value;
                    //List<string> ActionTilesAtk_Character = _responseJSON["ActionTilesAtk"].Value;
                    //List<string> ActionTilesDef_Character = _responseJSON["ActionTilesDef"].Value;
                    var walk = _responseJSON["WalkedTiles"];
                    for (int w_index = 0; w_index < walk.Count; w_index++)
                    {
                        _char_response.WalkedTiles.Add(walk[w_index]);
                        _char_response.CurrentTile = walk[w_index];
                    }

                    var actionAtk = _responseJSON["ActionTilesAtk"];
                    for (int aa_index = 0; aa_index < actionAtk.Count; aa_index++)
                    {
                        _char_response.ActionTilesAtk.Add(actionAtk[aa_index]);
                    }

                    var actionDef = _responseJSON["ActionTilesDef"];
                    for (int ad_index = 0; ad_index < actionDef.Count; ad_index++)
                    {
                        _char_response.ActionTilesDef.Add(actionDef[ad_index]);
                    }

                    _char_response.id        = id_Character;
                    _char_response.CurrentHP = CurrentHP_Character;
                    _char_response.CurrentAP = 10;



                    _ResponseP2.Add(_char_response);

                    //  ListToSend.Add(rootNode);
                }
                P2.TurnSend = true;
                return("Dados do Turno recebidos");
            }
        }
        return(null);
    }
Пример #11
0
        public override void OnInspectorGUI()
        {
            cSerializedObject.Update();
            if (!c.jointsFound)
            {
                GUILayout.Space(5);

                GUIStyle warningStyle = new GUIStyle();
                warningStyle.richText = true;
                GUILayout.Label("<color=maroon>Warning: Not all character joints was found!</color>", warningStyle);
                GUILayout.Label("<color=maroon>              Animation may look strange or not work at all.</color>", warningStyle);

                GUILayout.Space(5);
            }

            GUILayout.Space(10);
            var guiContent = new GUIContent();

            guiContent.text    = "Prefix for actors markers";
            guiContent.tooltip = "To use multiple actors, differient them from each other with a specific prefix on each marker and put the prefix here, e.g. \"Actor1_\"";

            var prefixText = EditorGUILayout.TextField(guiContent, c.ActorMarkersPrefix);

            if (prefixText != c.ActorMarkersPrefix)
            {
                c.ActorMarkersPrefix = prefixText;
                ResetIfActive(c);
            }

            GUILayout.Space(5);
            guiContent.text    = "Solve gaps using IK";
            guiContent.tooltip = "When markers are missing, the rotation and position of bones will be unknown.\nCheck this to use IK to predict bone positions in the skeleton";
            if (EditorGUILayout.Toggle(guiContent, c.UseIK) != c.UseIK)
            {
                c.UseIK = !c.UseIK;
                ResetIfActive(c);
            }

            guiContent.text    = "Use finger rotation";
            guiContent.tooltip = "Map the rotation of the actors fingers to the character in Unity";
            if (EditorGUILayout.Toggle(guiContent, c.UseFingers) != c.UseFingers)
            {
                c.UseFingers = !c.UseFingers;
                ResetIfActive(c);
            }

            guiContent.text    = "Scale movement to character size";
            guiContent.tooltip = "If the character is smaller or bigger then the actor, the character will float in the air or sink into the ground and move to much or to little.\nCheck this to scale the movement to the size of the character model.";
            if (EditorGUILayout.Toggle(guiContent, c.ScaleMovementToSize) != c.ScaleMovementToSize)
            {
                c.ScaleMovementToSize = !c.ScaleMovementToSize;
                ResetIfActive(c);
            }

            GUILayout.Space(5);
            guiContent.text    = "Character rotation model";
            guiContent.tooltip = "Characters have different definition of how each bone rotation, test different models if the character looks strange.\n\nHint: Change in Play mode will not be saved!";
            CharactersModel m = (CharactersModel)EditorGUILayout.EnumPopup(guiContent, c.model);

            if (m != c.model)
            {
                c.model = m;
                c.SetModelRotation();
            }
            EditorGUI.indentLevel++;
            {
                guiContent.text    = "Character rotations";
                guiContent.tooltip = "Fix each limb rotation by defining the euler angels here.";
                EditorGUILayout.PropertyField(boneRotation,
                                              guiContent, true);
                cSerializedObject.ApplyModifiedProperties();
            }
            EditorGUI.indentLevel--;
            GUILayout.Space(5);

            EditorGUILayout.BeginVertical();

            guiContent.text         = "Add camera to head";
            guiContent.tooltip      = "Attach a camera to the head of the character.";
            c.headCam.UseHeadCamera = EditorGUILayout.BeginToggleGroup(guiContent, c.headCam.UseHeadCamera);

            EditorGUI.indentLevel++;

            guiContent.text        = "Camera offset from head";
            guiContent.tooltip     = "The vector offset from the head joint to the camera, if zero, the camera will be placed in the middle of the head.\n\nHint: Change the Field of View in the camera settings in the Inspector under character -> CameraAnchor -> Camera";
            c.headCam.CameraOffset = EditorGUILayout.Vector3Field(guiContent, c.headCam.CameraOffset);

            guiContent.text                = "Set head rotation to VR device";
            guiContent.tooltip             = "Have this checked if using a Oculus Rift or other VR device who rotates the camera, otherwise rotation will be doubled.\n\nHint: No markers on the head is then necessary.";
            c.headCam.UseVRHeadSetRotation = EditorGUILayout.Toggle(guiContent, c.headCam.UseVRHeadSetRotation);

            guiContent.text    = "Recenter camera";
            guiContent.tooltip = "Recenter camera so that it looks the same way as the character.";
            if (GUILayout.Button(guiContent))
            {
                c.Recenter();
            }

            EditorGUI.indentLevel--;
            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.EndVertical();
        }
Пример #12
0
 public void OnModelChanged(CharactersModel characters)
 {
     controller.RefreshCharacters(characters);
 }
Пример #13
0
 public ModelManager(IWorldData worldData)
 {
     WeaponsModel    = new WeaponsModel(worldData.WeaponsData);
     CharactersModel = new CharactersModel(worldData.CharacterData, WeaponsModel);
     PlayersModel    = new PlayersModel(worldData.PlayersData, CharactersModel);
 }
    void SendActions()
    {
        SimpleJSON.JSONArray ListToSend = new SimpleJSON.JSONArray();
        Transform[]          p_group;

        if (GlobalVariables.Player_Team_Chosen == "A")
        {
            p_group = GameObject.Find("BLUE_SNAKES_Controller").GetComponentsInChildren <Transform>();
        }
        else
        {
            p_group = GameObject.Find("RED_SNAKES_Controller").GetComponentsInChildren <Transform>();
        }

        foreach (Transform child in p_group)
        {
            for (int i = 0; i < child.childCount; i++)
            {
                var character = child.GetChild(i);
                if (character.tag == "Player")
                {
                    CharactersModel _Character_Actions = new CharactersModel();

                    Player PlayerScript = character.GetComponent <Player>();

                    if (character.name == "Barbaro" || character.name == "Guerreiro")
                    {
                        foreach (var walk in GlobalVariables.WalkedMeele)
                        {
                            _Character_Actions.WalkedTiles.Add(walk.name);
                        }
                        foreach (var atk in GlobalVariables.ActionMeeleAtk)
                        {
                            _Character_Actions.ActionTilesAtk.Add(atk.name);
                        }
                        foreach (var def in GlobalVariables.ActionMeeleDef)
                        {
                            _Character_Actions.ActionTilesDef.Add(def.name);
                        }
                    }
                    else if (character.name == "Ranger" || character.name == "Arqueiro")
                    {
                        foreach (var walk in GlobalVariables.WalkedRange)
                        {
                            _Character_Actions.WalkedTiles.Add(walk.name);
                        }
                        foreach (var atk in GlobalVariables.ActionRangeAtk)
                        {
                            _Character_Actions.ActionTilesAtk.Add(atk.name);
                        }
                        foreach (var def in GlobalVariables.ActionRangeDef)
                        {
                            _Character_Actions.ActionTilesDef.Add(def.name);
                        }
                    }
                    else
                    {
                        foreach (var walk in GlobalVariables.WalkedMage)
                        {
                            _Character_Actions.WalkedTiles.Add(walk.name);
                        }
                        foreach (var atk in GlobalVariables.ActionMageAtk)
                        {
                            _Character_Actions.ActionTilesAtk.Add(atk.name);
                        }
                        foreach (var def in GlobalVariables.ActionMageDef)
                        {
                            _Character_Actions.ActionTilesDef.Add(def.name);
                        }
                    }

                    _Character_Actions.CurrentAP   = PlayerScript.ActionPoints;
                    _Character_Actions.CurrentHP   = PlayerScript.HP;
                    _Character_Actions.CurrentTile = PlayerScript.CurrentTile;
                    _Character_Actions.id          = PlayerScript.id;

                    ListToSend.Add(JsonUtility.ToJson(_Character_Actions));
                }
            }
        }
        GlobalVariables.__socket.SendData(ListToSend.ToString());
        GlobalVariables.__socket.StartReadSocketDataThread();
    }
 public void RefreshCharacters(CharactersModel model)
 {
     _allHeroes = model.Characters;
     MaybeRefreshCharacters();
 }
 public void RefreshHeroesModel(CharactersModel heroes)
 {
     _heroes = heroes.Characters;
 }
Пример #17
0
 public void OnModelChanged(CharactersModel model)
 {
     _heroesModel = model;
     Init();
 }