Exemplo n.º 1
0
 public ActionResult Save(CharModel model)
 {
     #region check duplicate
     forthead fhead = entities.fortheads.Where(x => x.CharName == model.CName).FirstOrDefault();
     #endregion
     bool isSave = false;
     if (fhead == null)
     {
         #region Save
         fhead = new forthead();
         entities.fortheads.Add(fhead);
         isSave      = true;
         ViewBag.msg = "New Char Is Saved";
         #endregion
     }
     else
     {
         ViewBag.msg = "New Char Is Updated";
     }
     #region Set Value
     fhead.CharName = model.CName;
     fhead.CharDesc = model.CDes;
     #endregion
     entities.SaveChanges();
     return(View());
 }
Exemplo n.º 2
0
        public ActionResult MyIndex(int?index)
        {
            int max = 5; // modify based on the actual number of records

            int currentIndex = index.GetValueOrDefault();

            if (currentIndex == 0)
            {
                ViewBag.NextIndex = 1;
            }
            else if (currentIndex >= max)
            {
                currentIndex          = max;
                ViewBag.PreviousIndex = currentIndex - 1;
            }
            else
            {
                ViewBag.PreviousIndex = currentIndex - 1;
                ViewBag.NextIndex     = currentIndex + 1;
            }

            CharModel objnews = new CharModel();
            CharModel model   = entities.fortheads.Select(x => new CharModel
            {
                ID    = x.ID,
                CName = x.CharName,
                CDes  = x.CharDesc,
            }).OrderBy(x => x.CName).Skip(currentIndex).Take(1).FirstOrDefault();

            return(View(model));
        }
Exemplo n.º 3
0
    void MouseUpdate()
    {
        //cursor.SetActive(true);
        Ray        vRay = cameraController.hitRay();
        RaycastHit hit  = new RaycastHit();

        if (Physics.Raycast(vRay, out hit, 100, rayLayerMask))
        {
            //Debug.DrawLine(vRay.origin, hit.point, Color.red);
            //Debug.Log(hit.transform.tag);
            if (hit.transform.tag == "Player")
            {
                guiController.SetCursorSelect();
            }
            else if ((hit.transform.tag == "Floor") && (iState == inputStates.CHAR_SELECTED))
            {
                //cursor.SetActive(false);
                guiController.SetCursorMove(getGridCenter(hit.point));
            }
            if (hit.transform.tag == "Enemy")
            {
                int cth = gameController.GetChanceToHit(hit.transform);
                guiController.SetCursorAim(cth);
                //Debug.Log(gameController.GetChanceToHit(hit.transform).ToString());
                if (Input.GetMouseButtonDown(1))
                {
                    gameController.ShootWeaponAt(hit.transform, cth);
                }
            }
        }

        //cursor.SetActive(false);
        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(vRay, out hit, 100, rayLayerMask))
            {
                if (hit.transform.tag == "Player")
                {
                    charModel = hit.transform.gameObject.GetComponent <CharModel>();
                    charModel.Select();
                    gameController.SelectPlayerObject(hit.transform.gameObject);
                    iState = inputStates.CHAR_SELECTED;
                    //cursor.SetActive(true);
                }
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            if (Physics.Raycast(vRay, out hit, 100, rayLayerMask))
            {
                if ((hit.transform.tag == "Floor") && (iState == inputStates.CHAR_SELECTED))
                {
                    gameController.MoveSelectedCharacter(getGridCenter(hit.point));
                }
            }
        }
    }
Exemplo n.º 4
0
        public ActionResult EditCharacter(CharModel model, int id)
        {
            ModelState.Clear();

            if (ModelState.IsValid)
            {
                try
                {
                    using (fantasyDbEntities context = new fantasyDbEntities())
                    {
                        Character character = new Character();
                        character = context.Character.Find(id);

                        // kontrola, zda string hodnoty nejsou null
                        if (model.CharName != null)
                        {
                            character.charname = model.CharName;
                        }
                        if (model.CharBio != null)
                        {
                            character.charbio = model.CharBio;
                        }
                        if (model.CharClass != null)
                        {
                            character.charclass = model.CharClass;
                        }
                        character.charlevel      = model.CharLevel;
                        character.charhp         = model.CharHp;
                        character.charmp         = model.CharMp;
                        character.strength       = model.CharStr;
                        character.chardurability = model.CharDurability;
                        character.idchar         = id;
                        try
                        {
                            // uložení všech změněných hodnot
                            context.Entry(character).State = EntityState.Modified;
                            context.SaveChanges();
                        }
                        catch (DbUpdateConcurrencyException ex)
                        {
                            var error = ex.ToString();
                            return(View());
                        }
                    }

                    return(RedirectToAction("Characters"));
                }
                catch (Exception exception)
                {
                    var error = exception.ToString();
                    return(View());
                }
            }
            return(View());
        }
Exemplo n.º 5
0
    private void LoadPlayer(CharModel charModel)
    {
        // Get the correct resources
        bool male = (charModel.gender == GenderType.MALE);

        rm = ResourceManager.Instance;

        player = new GameObject(charModel.name);

        LoadPlayerSkeleton(charModel);

        // Set layer to Players
        player.layer = LayerMask.NameToLayer("Players");

        //add PlayerController script
        PlayerController controller = player.AddComponent <PlayerController>();

        controller.rosePlayer       = this;
        controller.playerInfo.tMovS = charModel.stats.movSpd;

        //add Character controller
        Vector3 center = skeleton.transform.FindChild("b1_pelvis").localPosition;

        center.y = 0.95f;
        float height = 1.7f;
        float radius = Math.Max(playerBounds.extents.x, playerBounds.extents.y) / 2.0f;
        CharacterController charController = player.AddComponent <CharacterController>();

        charController.center = center;
        charController.height = height;
        charController.radius = radius;

        //add collider
        CapsuleCollider c = player.AddComponent <CapsuleCollider>();

        c.center    = center;
        c.height    = height;
        c.radius    = radius;
        c.direction = 1;         // direction y

        /*
         * //add event trigger
         * EventTrigger eventTrigger = player.AddComponent<EventTrigger>();
         * EventTrigger.Entry entry = new EventTrigger.Entry();
         * entry.eventID = EventTriggerType.PointerClick;
         * BaseEventData eventData = new BaseEventData(eventSystem);
         * eventData.selectedObject
         * entry.callback.AddListener( (eventData) => { controller.})
         */


        player.transform.position = charModel.pos;
        controller.SetAnimationStateMachine(charModel.rig, charModel.state);
    }
Exemplo n.º 6
0
    internal override void VirtualApply(ref WorldModel targetModel, Dictionary <Role, Character> involvedCharacters, float likelyhood)
    {
        Character OpinionHolderChar;

        if (!involvedCharacters.TryGetValue(OpinionHolder, out OpinionHolderChar))
        {
            return;                                                                       //unbound role
        }
        Character TraitHolderChar;

        if (!involvedCharacters.TryGetValue(TraitHolder, out TraitHolderChar))
        {
            return;                                                                   //unbound role
        }
        CharModel OpinionHolderModel;

        if (!targetModel.Characters.TryGetValue(OpinionHolderChar, out OpinionHolderModel))//no previous model
        {
            OpinionHolderModel = new CharModel(OpinionHolderChar);
            targetModel.Characters.Add(OpinionHolderChar, OpinionHolderModel);
        }
        OpinionModel opinions;

        if (!OpinionHolderModel.opinions.TryGetValue(TraitHolderChar, out opinions))//no modeled opinions about traitHolder
        {
            opinions = new OpinionModel();
            OpinionHolderModel.opinions.Add(TraitHolderChar, opinions);
        }
        float previousValue;

        if (!opinions.traits.TryGetValue(trait, out previousValue))
        {
            previousValue = 0.5f;
            opinions.traits.Add(trait, previousValue);
        }
        switch (Operator)
        {
        case ValueChangeOperator.add:
            opinions.traits[trait] = Mathf.Clamp01(previousValue + traitValue);
            break;

        case ValueChangeOperator.multiply:
            opinions.traits[trait] = Mathf.Clamp01(previousValue * traitValue);
            break;

        case ValueChangeOperator.set:
            opinions.traits[trait] = Mathf.Clamp01(traitValue);
            break;

        default:
            break;
        }
    }
Exemplo n.º 7
0
        public ActionResult NewCharacter(CharModel model)
        {
            if (ModelState.IsValid)
            {
                using (fantasyDbEntities context = new fantasyDbEntities())
                {
                    // vytvoření nové entity postavy
                    Character player = new Character();
                    player.charname = model.CharName;
                    player.charbio  = model.CharBio;

                    // hardcoded starting values
                    player.charhp         = 20;
                    player.charlevel      = 1;
                    player.charmp         = 10;
                    player.charxp         = 0;
                    player.strength       = 5;
                    player.agility        = 5;
                    player.chardurability = 5;
                    player.intelligence   = 5;

                    // pokud uživatel nevybrat žádnou profesi
                    if (model.CharClass == null)
                    {
                        // nastaví profesi za uživatele
                        player.charclass = "Warrior";
                    }
                    else
                    {
                        player.charclass = model.CharClass;
                    }

                    player.playername = User.Identity.GetUserName();
                    // přidání a uložení nové postavy
                    context.Character.Add(player);
                    context.SaveChanges();

                    // automatické založení inventáře pro každou novou postavu
                    Inventory inventory = new Inventory();
                    inventory.maxspace  = 10;
                    inventory.freespace = 10;
                    inventory.ownerid   = player.idchar;
                    context.Inventory.Add(inventory);
                    context.SaveChanges();
                }
            }
            else
            {
                return(RedirectToAction("Characters"));
            }

            return(RedirectToAction("Characters"));
        }
Exemplo n.º 8
0
    internal CharModel copy()
    {
        var result = new CharModel();

        result.Character = Character;
        result.traits    = new TraitValueDictionary();
        result.traits.CopyFrom(traits);
        result.goals         = new List <Goal>(goals);
        result.Relationships = new RelationShipDictionary();
        result.Relationships.CopyFrom(Relationships);
        result.opinions = new OpinionDictionary();
        result.opinions.CopyFrom(opinions);
        return(result);
    }
Exemplo n.º 9
0
        public ActionResult Descshow(string id)
        {
            #region data display
            int       ID    = Convert.ToInt32(id);
            CharModel model = new CharModel();
            model = entities.fortheads.Where(x => x.ID == ID).Select(x => new CharModel
            {
                ID   = x.ID,
                CDes = x.CharDesc,
            }).FirstOrDefault();
            return(Json(model.CDes, JsonRequestBehavior.AllowGet));

            #endregion
        }
Exemplo n.º 10
0
    internal override void VirtualApply(ref WorldModel targetModel, Dictionary <Role, Character> involvedCharacters, float likelyhood)
    {
        Character OpinionHolderChar;

        if (!involvedCharacters.TryGetValue(OpinionHolder, out OpinionHolderChar))
        {
            return;                                                                       //unbound role
        }
        Character RelationshipHolderChar;

        if (!involvedCharacters.TryGetValue(RelationshipHolder, out RelationshipHolderChar))
        {
            return;
        }
        Character RelationshipRecipientChar;

        if (!involvedCharacters.TryGetValue(RelationshipRecipient, out RelationshipRecipientChar))
        {
            return;
        }
        CharModel OpinionHolderModel;

        if (!targetModel.Characters.TryGetValue(OpinionHolderChar, out OpinionHolderModel))//no previous model
        {
            OpinionHolderModel = new CharModel(OpinionHolderChar);
            targetModel.Characters.Add(OpinionHolderChar, OpinionHolderModel);
        }
        OpinionModel opinions;

        if (!OpinionHolderModel.opinions.TryGetValue(RelationshipHolderChar, out opinions))
        {
            opinions = new OpinionModel();
            OpinionHolderModel.opinions.Add(RelationshipHolderChar, opinions);
        }
        RelationshipArray relationships;

        if (!opinions.relationships.TryGetValue(RelationshipRecipientChar, out relationships))//no previous relationship modeled for the recipient
        {
            relationships = new RelationshipArray();
        }
        if (RelationshipStatus && !relationships.relationships.Contains(relationship))
        {
            relationships.relationships.Add(relationship);
        }
        else if (!RelationshipStatus && relationships.relationships.Contains(relationship))
        {
            relationships.relationships.Remove(relationship);
        }
    }
Exemplo n.º 11
0
 private void LoadPlayerSkeleton(CharModel charModel)
 {
     LoadPlayerSkeleton(
         charModel.gender,
         charModel.weapon,
         charModel.rig,
         charModel.equip.weaponID,
         charModel.equip.chestID,
         charModel.equip.handID,
         charModel.equip.footID,
         charModel.equip.hairID,
         charModel.equip.faceID,
         charModel.equip.backID,
         charModel.equip.capID,
         charModel.equip.shieldID);
 }
Exemplo n.º 12
0
        public async Task <IHttpActionResult> PostUserInfo(CharModel charModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (await GetCurrentUserInfo() != null)
            {
                return(BadRequest("Пользователь уже создан"));
            }

            await CreateUserInfo(charModel);

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 13
0
    internal override void Apply(Dictionary <Role, Character> involvedCharacters)
    {
        Character OpinionHolderCharacter;

        if (!involvedCharacters.TryGetValue(OpinionHolder, out OpinionHolderCharacter))
        {
            return;
        }
        Character TraitHolderCharacter;

        if (!involvedCharacters.TryGetValue(TraitHolder, out TraitHolderCharacter))
        {
            return;
        }
        CharModel TraitHolderModel;

        if (!OpinionHolderCharacter.worldModel.Characters.TryGetValue(TraitHolderCharacter, out TraitHolderModel))
        {
            TraitHolderModel = new CharModel(TraitHolderCharacter);
            OpinionHolderCharacter.worldModel.Characters.Add(TraitHolderCharacter, TraitHolderModel);
        }
        float previousValue;

        if (!TraitHolderModel.traits.TryGetValue(trait, out previousValue))
        {
            previousValue = 0.5f;//assume average
            TraitHolderModel.traits.Add(trait, previousValue);
        }
        switch (Operator)
        {
        case ValueChangeOperator.add:
            TraitHolderModel.traits[trait] = Mathf.Clamp01(previousValue + traitValue);
            break;

        case ValueChangeOperator.multiply:
            TraitHolderModel.traits[trait] = Mathf.Clamp01(previousValue * traitValue);
            break;

        case ValueChangeOperator.set:
            TraitHolderModel.traits[trait] = Mathf.Clamp01(traitValue);
            break;

        default:
            Debug.LogError("invalid Value change operator : " + Operator.ToString());
            break;
        }
    }
Exemplo n.º 14
0
    internal void ConstructownModel()//should only be called once per character, as it keeps references to the real values;
    {
        var model = new CharModel();

        model.Character     = this;
        model.goals         = m_goals;
        model.Relationships = m_relationships;
        model.traits        = m_traits;
        if (worldModel.Characters.ContainsKey(this))
        {
            worldModel.Characters[this] = model;
        }
        else
        {
            worldModel.Characters.Add(this, model);
        }
    }
        /*user add new model -> create a new CharModel obj*/
        public CharModel modelObj(string charName, string faction, int rank, int size, string deploymentZone, int _base, string actionName, string spcAbiName)
        {
            Models.Action actionsDef = new Models.Action
            {
                name   = actionName,
                type   = "",
                rating = 0,
                range  = ""
            };
            List <Models.Action> actionsCollection = new List <Models.Action> {
            };

            actionsCollection.Add(actionsDef);
            Models.SpecialAbility specialAbilitiesDef = new Models.SpecialAbility
            {
                name        = spcAbiName,
                description = "N/A"
            };
            List <Models.SpecialAbility> specialAbilities = new List <Models.SpecialAbility> {
            };

            specialAbilities.Add(specialAbilitiesDef);
            CharModel obj = new CharModel
            {
                charName         = charName,
                faction          = faction,
                rank             = rank,
                _base            = _base,
                size             = size,
                deploymentZone   = "C",
                traits           = new string[] { "N/A" },
                types            = new string[] { "N/A" },
                defenseChart     = new string[] { "N/A" },
                mobility         = 0,
                willpower        = 0,
                resiliance       = 0,
                wounds           = 0,
                actions          = actionsCollection,
                specialAbilities = specialAbilities,
                imageUrl         = "N/A"
            };

            return(obj);
        }
Exemplo n.º 16
0
    internal override void Apply(Dictionary <Role, Character> involvedCharacters)
    {
        Character OpinionHolderCharacter;

        if (!involvedCharacters.TryGetValue(OpinionHolder, out OpinionHolderCharacter))
        {
            return;
        }
        Character RelationshipHolderChar;

        if (!involvedCharacters.TryGetValue(RelationshipHolder, out RelationshipHolderChar))
        {
            return;
        }
        Character RelationshipRecipientChar;

        if (!involvedCharacters.TryGetValue(RelationshipRecipient, out RelationshipRecipientChar))
        {
            return;
        }
        CharModel RelationshipHolderModel;

        if (!OpinionHolderCharacter.worldModel.Characters.TryGetValue(RelationshipHolderChar, out RelationshipHolderModel))
        {
            RelationshipHolderModel = new CharModel(RelationshipHolderChar);
            OpinionHolderCharacter.worldModel.Characters.Add(RelationshipHolderChar, RelationshipHolderModel);
        }
        RelationshipArray relationshipArray;

        if (!RelationshipHolderModel.Relationships.TryGetValue(RelationshipRecipientChar, out relationshipArray))
        {
            relationshipArray = new RelationshipArray();
            RelationshipHolderModel.Relationships.Add(RelationshipRecipientChar, relationshipArray);
        }
        if (RelationshipStatus && !relationshipArray.relationships.Contains(relationship))
        {
            relationshipArray.relationships.Add(relationship);
        }
        else if (!RelationshipStatus && relationshipArray.relationships.Contains((relationship)))
        {
            relationshipArray.relationships.Remove(relationship);
        }
    }
Exemplo n.º 17
0
        public async Task <IHttpActionResult> PutUserInfo(CharModel charModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var user = await GetCurrentUserInfo();

            if (user == null)
            {
                return(Ok());
            }
            user.Level      = charModel.Level;
            user.Type       = charModel.Type;
            user.Experience = charModel.Experience;

            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 18
0
        // zobrazení stránky EditCharacter - zasílající zvolené ID hráče
        public ActionResult EditCharacter(int id)
        {
            using (fantasyDbEntities context = new fantasyDbEntities())
            {
                var character = context.Character.Where(x => x.idchar == id).FirstOrDefault();

                // vytvoření instance CharModelu a načtení všech aktuálních hodnot
                CharModel model = new CharModel();
                model.CharID         = id;
                model.CharName       = character.charname;
                model.CharBio        = character.charbio;
                model.CharClass      = character.charclass;
                model.CharLevel      = character.charlevel;
                model.CharHp         = character.charhp;
                model.CharMp         = character.charmp;
                model.CharStr        = (int)character.strength;
                model.CharDurability = (int)character.chardurability;

                return(View(model));
            }
        }
Exemplo n.º 19
0
        private async Task CreateUserInfo(CharModel charModel)
        {
            var newInfo = new UserInfo
            {
                Type = charModel.Type,
                Name = charModel.Name
            };

            db.UserInfos.Add(newInfo);
            await db.SaveChangesAsync();

            var userId = RequestContext.Principal.Identity.GetUserId();
            var user   = await db.Set <ApplicationUser>()
                         .Where(e => e.Id == userId)
                         .FirstOrDefaultAsync();

            db.Set <ApplicationUser>().Attach(user);
            user.UserInfo = newInfo;
            await db.SaveChangesAsync();

            var availableCardsIds = new[] { 1, 2, 3 };
            var cards             = db.Card.Where(c => availableCardsIds.Contains(c.Id)).ToArray();

            db.AvailableCards.AddRange(new[]
            {
                new AvailableCards {
                    UserInfo = newInfo, Card = cards[0], CardStatus = CardStatus.NotActive
                },
                new AvailableCards {
                    UserInfo = newInfo, Card = cards[1], CardStatus = CardStatus.NotActive
                },
                new AvailableCards {
                    UserInfo = newInfo, Card = cards[2], CardStatus = CardStatus.NotActive
                }
            });
            db.SaveChanges();
        }
Exemplo n.º 20
0
    internal override void VirtualApply(ref WorldModel targetModel, Dictionary <Role, Character> involvedCharacters, float likelyhood)
    {
        Character HolderChar;
        Character RecipientChar;

        if (!involvedCharacters.TryGetValue(Holder, out HolderChar))
        {
            return;                                                         //unbound role
        }
        if (!involvedCharacters.TryGetValue(Recipient, out RecipientChar))
        {
            return;                                                               //unbound role
        }
        CharModel HolderModel;

        if (!targetModel.Characters.TryGetValue(HolderChar, out HolderModel)) //no previous model of the holder
        {
            HolderModel = new CharModel(HolderChar);                          //assuming no relationship
        }
        RelationshipArray relationshipModel;

        if (!HolderModel.Relationships.TryGetValue(RecipientChar, out relationshipModel))//no known relationship with the recipient
        {
            relationshipModel = new RelationshipArray();
            HolderModel.Relationships.Add(RecipientChar, relationshipModel);
        }
        //There are only two cases I can think of at the moment
        if (status && !relationshipModel.relationships.Contains(relationship))
        {
            relationshipModel.relationships.Add(relationship);
        }
        else if (!status && relationshipModel.relationships.Contains(relationship))
        {
            relationshipModel.relationships.Remove(relationship);
        }
    }
Exemplo n.º 21
0
    static public GameObject CreateChar(CharSex eSex         = CharSex.eWoman,
                                        CharModel eModel     = CharModel.eOne,
                                        CharForWhat eForWhat = CharForWhat.eInterior,
                                        bool bNeedCollider   = false,
                                        bool bNeedLight      = true)
    {
        GameObject cGO       = Resources.Load("player/Char/" + strPrefabName[(int)eSex, (int)eModel]) as GameObject;
        GameObject cMainChar = Utility.Instantiate(cGO) as GameObject;

        cMainChar.name            = cGO.name + (++nNameSerial).ToString();
        strCurMainCharGameObjName = cMainChar.name;

        ChangeCharTransform(strCurMainCharGameObjName, eForWhat);

        if (eForWhat == CharForWhat.eDancingLeft)
        {
            cMainChar.transform.Rotate(new Vector3(0, 160, 0));
        }
        else if (eForWhat == CharForWhat.eDancingRight)
        {
            cMainChar.transform.Rotate(new Vector3(0, -160, 0));
        }
        else
        {
            cMainChar.transform.Rotate(new Vector3(0, 180, 0));
        }

        if ((int)eForWhat <= (int)CharForWhat.eWaitingRoomRight)
        {
            cMainChar.AddComponent <DcCharacterShadow>();
            DcCharAnim cCharAnim = cMainChar.GetComponent(typeof(DcCharAnim)) as DcCharAnim;
            if (cCharAnim)
            {
                //cCharAnim.bIsAutoPlaySpecialIdle = true;
            }
        }

        if (bNeedCollider)
        {
            cMainChar.layer = LayerMask.NameToLayer("GameUILayout");
            for (int i = 0; i < cMainChar.transform.childCount; i++)
            {
                GameObject child = cMainChar.transform.GetChild(i).gameObject;
                child.layer = LayerMask.NameToLayer("GameUILayout");
            }
            BoxCollider cBoxColl = cMainChar.AddComponent <BoxCollider>();
            //BoxCollider cBoxColl = gameObject.GetComponent<BoxCollider>();
            if (eSex == CharSex.eMan)
            {
                cBoxColl.center = new Vector3(0, 34.8f, 0);
                cBoxColl.size   = new Vector3(20f, 72.1f, 15f);
            }
            else
            {
                cBoxColl.center = new Vector3(0, 30.7f, 0);
                cBoxColl.size   = new Vector3(20f, 62.7f, 15f);
            }
        }
        else
        {
            cMainChar.layer = LayerMask.NameToLayer("Default");
            for (int i = 0; i < cMainChar.transform.childCount; i++)
            {
                GameObject child = cMainChar.transform.GetChild(i).gameObject;
                child.layer = LayerMask.NameToLayer("Default");
            }
        }

        if (bNeedLight)
        {
            GameObject cL = GameObject.Find("DirLight");
            if (!cL)
            {
                cGO = Resources.Load("player/Light/DirLight") as GameObject;
                GameObject cDirLight = Utility.Instantiate(cGO) as GameObject;
                cDirLight.name = cGO.name;
            }
        }

        return(cMainChar);
    }
Exemplo n.º 22
0
 public RosePlayer(Vector3 position)
 {
     charModel     = new CharModel();
     charModel.pos = position;
     LoadPlayer(charModel);
 }
Exemplo n.º 23
0
 public RosePlayer(CharModel charModel)
 {
     this.charModel = charModel;
     LoadPlayer(charModel);
 }
Exemplo n.º 24
0
 public RosePlayer(GenderType gender)
 {
     charModel        = new CharModel();
     charModel.gender = gender;
     LoadPlayer(charModel);
 }
Exemplo n.º 25
0
 public RosePlayer()
 {
     charModel = new CharModel();
     LoadPlayer(charModel);
 }
Exemplo n.º 26
0
    /*
     * private RosePatch ImportPatch(string inputDir, Transform terrainParent, Transform objectsParent)
     * {
     *      // Patch consists of the following elements:
     *      //	- .HIM file specifying the heighmap of the terrain: 65x65 image of floats
     *      //	- .TIL file specifying the texture tileset: 16x16 tiles, containing ID's that index into .ZON.Tiles, which returns index into .ZON.Textures
     *      //  - TODO: add other fileTypes here after researching
     *
     *
     *      bool success = true;
     *
     *      Debug.Log ("Importing patch from " + inputDir + "...");
     *
     *      RosePatch patch = new RosePatch(new DirectoryInfo(inputDir));
     *
     *      success &= patch.Load();
     *      success &= patch.Import(terrainParent, objectsParent);
     *
     *
     *      if(success)
     *              Debug.Log ("Patch Import complete");
     *      else
     *              Debug.Log ("!Patch Import failed");
     *
     *      return patch;
     * }
     */

    void OnGUI()
    {
        // Need to do the following:
        // - Specify a specific map to load (path + directory browser?)
        // - Specify an output directory (path + directory browser?)
        // - Button to begin conversion
        // - add any extra settings here ...

        // ----------------Example GUI elements-----------------------
        // GUILayout.Label ("Settings", EditorStyles.boldLabel);
        // myBool = EditorGUILayout.Toggle ("Toggle", myBool);
        // myFloat = EditorGUILayout.Slider ("Slider", myFloat, -3, 3);
        // -----------------------------------------------------------

        //=================== MAP =======================

        EditorGUILayout.BeginToggleGroup("Map", true);
        m_inputDir = EditorGUILayout.TextField("Input dir: ", m_inputDir);

        /*
         * if(GUILayout.Button("Import"))
         * {
         *      STB stb = new STB(m_inputDir);
         *      // STL:
         *      //		  row		  col   row
         *      //Entries[0-62]  Rows[0-5][0-61]
         *      //LZON001  korean "Canyon City of Zant" korean korean korean
         *      //LZON002  korean "City of Junon Polis" korean korean korean
         *      //LZON003  korean "Junon Cartel" ...
         *      //...
         *
         *
         *      int x=1;
         * }
         */


        if (GUILayout.Button("Import"))
        {
            // Several options based on the given path
            // 1. 3DDATA/MAPS/						-> convert rose universe
            // 2. 3DDATA/MAPS/JUNON					-> convert rose planet
            // 3. 3DDATA/MAPS/JUNON/JPT01			-> convert rose map
            // 4. 3DDATA/MAPS/JUNON/JTP01/30_30		-> convert rose patch
            // 5. Some/invalid/path
            bool          notFound  = false;
            DirectoryInfo inDirInfo = new DirectoryInfo(m_inputDir);
            switch (inDirInfo.Name.ToLower())
            {
            case "maps":                                                        // 1.
                ImportGalaxy();
                break;

            case "junon":                                                       // 2.
            case "eldeon":
            case "lunar":
                // TODO: add any new planets here...
                ImportPlanet();
                break;

            default:
                notFound = true;
                break;
            }             // switch

            if (notFound)
            {
                switch (inDirInfo.Parent.Name.ToLower())
                {
                case "junon":                                           // 3.
                case "eldeon":
                case "lunar":
                    // TODO: add any new planets here...
                    ImportMap(inDirInfo.Name.ToLower());
                    break;

                default:
                    GameObject terrain = new GameObject();
                    terrain.name = "Terrain";

                    GameObject terrainObjects = new GameObject();
                    terrainObjects.name = "Terrain Objects";
                    //ImportPatch(m_inputDir, terrain.transform, terrainObjects.transform);			// 4. (LoadPatch will handle 5. properly)
                    break;
                } // switch
            }     // if
        }         // if

        EditorGUILayout.EndToggleGroup();
        // ======================== OBJECT ==========================
        EditorGUILayout.BeginToggleGroup("Animated Object", true);
        m_szcPath = EditorGUILayout.TextField("ZSC: ", m_szcPath);
        objID     = EditorGUILayout.IntField("ID: ", objID);
        bodyPart  = EditorGUILayout.IntField("Body Part: ", bodyPart);
        transform = EditorGUILayout.ObjectField("Transform: ", transform, typeof(Transform), true) as Transform;
        if (GUILayout.Button("Create"))
        {
            if (transform != null)
            {
                player = new RosePlayer(transform.position);                  // Note: Player reference is lost after hitting play.  Must create new after that.
            }
            else
            {
                player = new RosePlayer();
            }
        }

        if (GUILayout.Button("Create Char Select"))
        {
            CharModel model = new CharModel();
            model.rig   = RigType.CHARSELECT;
            model.state = States.HOVERING;

            if (transform != null)
            {
                model.pos = transform.position;
            }

            player = new RosePlayer(model); // Note: Player reference is lost after hitting play.  Must create new after that.
        }

        if (GUILayout.Button("Equip"))
        {
            if (player != null)
            {
                player.equip((BodyPartType)bodyPart, objID);
            }

            //RosePlayer player = new RosePlayer(GenderType.MALE, WeaponType.THSWORD);
            //ResourceManager.Instance.GenerateAnimationAsset(GenderType.MALE, WeaponType.EMPTY);
            //ResourceManager.Instance.GenerateAnimationAssets();
            //GenerateCharSelectAnimations();
        }

        if (GUILayout.Button("GenerateAnimations"))
        {
            //RosePlayer player = new RosePlayer(GenderType.MALE, WeaponType.THSWORD);
            //ResourceManager.Instance.GenerateAnimationAsset(GenderType.MALE, WeaponType.EMPTY);
            //ResourceManager.Instance.GenerateAnimationAssets();
            GenerateCharSelectAnimations();
        }

        EditorGUILayout.EndToggleGroup();
    }     // OnGui()
Exemplo n.º 27
0
    public static GameObject CreateChar(CharSex eSex = CharSex.eWoman,
                                        CharModel eModel = CharModel.eOne,
                                        CharForWhat eForWhat = CharForWhat.eInterior,
                                        bool bNeedCollider = false,
                                        bool bNeedLight = true)
    {
        GameObject cGO = Resources.Load("player/Char/"+strPrefabName[(int)eSex,(int)eModel]) as GameObject;
        GameObject cMainChar = Utility.Instantiate(cGO) as GameObject;
        cMainChar.name = cGO.name + (++nNameSerial).ToString();
        strCurMainCharGameObjName = cMainChar.name;

        ChangeCharTransform(strCurMainCharGameObjName,eForWhat);

        if(eForWhat == CharForWhat.eDancingLeft)
        {
            cMainChar.transform.Rotate(new Vector3(0, 160, 0));
        }
        else if(eForWhat == CharForWhat.eDancingRight)
        {
            cMainChar.transform.Rotate(new Vector3(0, -160, 0));
        }
        else
        {
            cMainChar.transform.Rotate(new Vector3(0, 180, 0));
        }

        if((int)eForWhat <= (int)CharForWhat.eWaitingRoomRight)
        {
            cMainChar.AddComponent<DcCharacterShadow>();
            DcCharAnim cCharAnim = cMainChar.GetComponent(typeof(DcCharAnim)) as DcCharAnim;
            if(cCharAnim)
            {
                //cCharAnim.bIsAutoPlaySpecialIdle = true;
            }
        }

        if(bNeedCollider)
        {
            cMainChar.layer = LayerMask.NameToLayer("GameUILayout");
            for(int i=0;i<cMainChar.transform.childCount;i++)
            {
                GameObject child = cMainChar.transform.GetChild(i).gameObject;
                child.layer = LayerMask.NameToLayer("GameUILayout");
            }
            BoxCollider cBoxColl = cMainChar.AddComponent<BoxCollider>();
            //BoxCollider cBoxColl = gameObject.GetComponent<BoxCollider>();
            if(eSex == CharSex.eMan)
            {
                cBoxColl.center = new Vector3(0, 34.8f, 0);
                cBoxColl.size = new Vector3(20f, 72.1f, 15f);
            }
            else
            {
                cBoxColl.center = new Vector3(0, 30.7f, 0);
                cBoxColl.size = new Vector3(20f, 62.7f, 15f);
            }
        }
        else
        {
            cMainChar.layer = LayerMask.NameToLayer("Default");
            for(int i=0;i<cMainChar.transform.childCount;i++)
            {
                GameObject child = cMainChar.transform.GetChild(i).gameObject;
                child.layer = LayerMask.NameToLayer("Default");
            }
        }

        if(bNeedLight)
        {
            GameObject cL = GameObject.Find("DirLight");
            if(!cL)
            {
           		cGO = Resources.Load("player/Light/DirLight") as GameObject;
                GameObject cDirLight = Utility.Instantiate(cGO) as GameObject;
                cDirLight.name = cGO.name;
            }
        }

        return cMainChar;
    }
Exemplo n.º 28
0
 public CharSelectPacket(CharModel charModel)
 {
     operation      = (int)UserOperation.CREATECHAR;
     this.charModel = charModel;
 }