コード例 #1
0
ファイル: Jumjaro.cs プロジェクト: teamdotsix/jumjaro
 private void ResetNumberMode()
 {
     if (_characterMode == CharacterMode.Number)
     {
         _characterMode = CharacterMode.None;
     }
 }
コード例 #2
0
ファイル: Creature.cs プロジェクト: chengjingfeng/dwarfcorp
        public IEnumerable <Act.Status> HitAndWait(bool loadBar, Func <float> maxProgress,
                                                   Func <float> progress, Action incrementProgress,
                                                   Func <Vector3> pos, string playSound = "", Func <bool> continueHitting = null, bool maintainPos = true)
        {
            Vector3 currentPos = Physics.LocalTransform.Translation;

            CurrentCharacterMode = Stats.CurrentClass.AttackMode;
            Sprite.ResetAnimations(CurrentCharacterMode);
            Sprite.PlayAnimations(CurrentCharacterMode);
            var   p_current      = pos();
            Timer incrementTimer = new Timer(1.0f, false);

            while (progress() < maxProgress())
            {
                if (continueHitting != null && !continueHitting())
                {
                    yield break;
                }

                if (loadBar)
                {
                    Drawer2D.DrawLoadBar(Manager.World.Renderer.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4,
                                         progress() / maxProgress());
                }
                Physics.Active = false;
                Physics.Face(p_current);
                if (Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, p_current))
                {
                    p_current = pos();
                }
                Physics.Velocity = Vector3.Zero;

                if (!String.IsNullOrEmpty(playSound))
                {
                    NoiseMaker.MakeNoise(playSound, AI.Position, true);
                }

                incrementTimer.Update(DwarfTime.LastTime);
                if (incrementTimer.HasTriggered)
                {
                    Sprite.ReloopAnimations(Stats.CurrentClass.AttackMode);
                    incrementProgress();
                }

                if (maintainPos)
                {
                    var matrix = Physics.LocalTransform;
                    matrix.Translation     = currentPos;
                    Physics.LocalTransform = matrix;
                }

                yield return(Act.Status.Running);
            }
            Sprite.PauseAnimations(Stats.CurrentClass.AttackMode);
            CurrentCharacterMode = CharacterMode.Idle;
            Physics.Active       = true;
            yield return(Act.Status.Success);

            yield break;
        }
コード例 #3
0
ファイル: Character.cs プロジェクト: GiorgiIS/Mario
        public void Eat(Mushroom mushroom)
        {
            if (IsDead)
            {
                Console.WriteLine("Character is dead");
                return;
            }

            bool wasEatenSuccessfully = mushroom.WasEatenSuccessfully();

            if (wasEatenSuccessfully)
            {
                if (mushroom.MushroomType == MushroomType.Bad)
                {
                    RecieveDamage(mushroom.DamagePoint);
                }
                else if (mushroom.MushroomType == MushroomType.Good)
                {
                    CharacterMode = CharacterMode.Big;
                }
                else
                {
                    throw new ArgumentException("Unknown MushroomType was provided.");
                }
            }
        }
コード例 #4
0
        public static Character GetCharacter(TContext ctx, CharacterMode mode, string auth, string clientUUID)
        {
            int userId = 0;
            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);

                if (user == null)
                {
                    OTA.Logging.ProgramLog.Error.Log("No user found ");
                    return null;
                }

                userId = user.Id;
            }
            else if (mode != CharacterMode.UUID)
                return null;

            if (mode == CharacterMode.AUTH)
            {
                return ctx.Characters.SingleOrDefault(x => x.UserId == userId);
            }
            else
            {
                return ctx.Characters.SingleOrDefault(x => x.UUID == clientUUID);
            }
        }
コード例 #5
0
ファイル: Creature.cs プロジェクト: chengjingfeng/dwarfcorp
        /// <summary>
        /// Basic Act that causes the creature to wait for the specified time.
        /// Also draws a loading bar above the creature's head when relevant.
        /// </summary>
        public IEnumerable <Act.Status> HitAndWait(float f, bool loadBar, Func <Vector3> pos)
        {
            var waitTimer = new Timer(f, true);

            CurrentCharacterMode = Stats.CurrentClass.AttackMode;
            Sprite.ResetAnimations(CurrentCharacterMode);
            Sprite.PlayAnimations(CurrentCharacterMode);

            while (!waitTimer.HasTriggered)
            {
                waitTimer.Update(DwarfTime.LastTime);

                if (loadBar)
                {
                    Drawer2D.DrawLoadBar(Manager.World.Renderer.Camera, AI.Position + Vector3.Up, Color.LightGreen, Color.Black, 64, 4, waitTimer.CurrentTimeSeconds / waitTimer.TargetTimeSeconds);
                }

                Physics.Active = false;

                Attacks[0].PerformNoDamage(this, DwarfTime.LastTime, pos());
                Physics.Velocity = Vector3.Zero;
                Sprite.ReloopAnimations(Stats.CurrentClass.AttackMode);

                yield return(Act.Status.Running);
            }

            Sprite.PauseAnimations(Stats.CurrentClass.AttackMode);
            CurrentCharacterMode = CharacterMode.Idle;
            Physics.Active       = true;

            yield return(Act.Status.Success);

            yield break;
        }
コード例 #6
0
    protected void exitCar()
    {
        //sai do carro
        CharMode = CharacterMode.WALKING_MODE;

        var positionToGo = transform.position;

        positionToGo.y     = positionToGo.y + 5;
        transform.position = positionToGo;

        Model.SetActive(true);

        collider.isTrigger   = false;
        rigidbody.useGravity = true;
        // detectObjects.carNearby.GetComponent<WheelVehicle>().IsPlayer = false;

        var car = detectObjects.carNearby.GetComponent <WheelVehicle>();

        if (car.GetCarOwner().gameObject.tag == "Player")
        {
            car.IsPlayer = false;
        }
        car.ResetCarOwner();
        car = null;
    }
コード例 #7
0
        public static Character GetCharacter(TContext ctx, CharacterMode mode, string auth, string clientUUID)
        {
            int userId = 0;

            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);

                if (user == null)
                {
                    OTA.Logging.ProgramLog.Error.Log("No user found ");
                    return(null);
                }

                userId = user.Id;
            }
            else if (mode != CharacterMode.UUID)
            {
                return(null);
            }

            if (mode == CharacterMode.AUTH)
            {
                return(ctx.Characters.SingleOrDefault(x => x.UserId == userId));
            }
            else
            {
                return(ctx.Characters.SingleOrDefault(x => x.UUID == clientUUID));
            }
        }
コード例 #8
0
    //entra no carro
    protected void enterCar()
    {
        if (detectObjects.carNearby != null)
        {//verifica carro proximo
            var car = detectObjects.carNearby.GetComponent <WheelVehicle>();
            if (car.GetCarOwner() == null)
            {
                //entra no carro
                CharMode             = CharacterMode.CAR_MODE;
                rigidbody.velocity   = Vector3.zero;
                rigidbody.useGravity = false;
                collider.isTrigger   = true;
                Model.SetActive(false);

                var positionToGo = detectObjects.carNearby.transform.position;
                transform.position = positionToGo;
                transform.rotation = detectObjects.carNearby.transform.rotation;

                //


                car.SetCarOwner(this);
                if (car.GetCarOwner().gameObject.tag == "Player")
                {
                    car.IsPlayer = true;
                }
            }
        }
    }
コード例 #9
0
ファイル: CharacterSprite.cs プロジェクト: kyroskoh/dwarfcorp
 public List <Animation> GetAnimations(CharacterMode mode)
 {
     return
         (OrientationStrings.Where((t, i) => HasAnimation(mode, (Orientation)i))
          .Select(t => Animations[mode.ToString() + t])
          .ToList());
 }
コード例 #10
0
ファイル: CharacterSprite.cs プロジェクト: kyroskoh/dwarfcorp
        public static Animation CreateAnimation(CharacterMode mode,
                                                Orientation orient,
                                                SpriteSheet texture,
                                                float frameHz,
                                                int frameWidth,
                                                int frameHeight,
                                                int row,
                                                List <int> cols)
        {
            List <Point> frames  = new List <Point>();
            int          numCols = texture.Width / frameWidth;

            if (cols.Count == 0)
            {
                for (int i = 0; i < numCols; i++)
                {
                    frames.Add(new Point(i, row));
                }
            }
            else
            {
                frames.AddRange(cols.Select(c => new Point(c, row)));
            }

            return(new Animation(GameState.Game.GraphicsDevice, texture, mode.ToString() + OrientationStrings[(int)orient], frameWidth, frameHeight, frames, true, Color.White, frameHz, (float)frameWidth / 35.0f, (float)frameHeight / 35.0f, false));
        }
コード例 #11
0
ファイル: CharacterSprite.cs プロジェクト: sodomon2/dwarfcorp
 public void ReloopAnimations(CharacterMode mode)
 {
     SetCurrentAnimation(mode.ToString(), true);
     if (AnimPlayer.IsDone())
     {
         AnimPlayer.Reset();
     }
 }
コード例 #12
0
 public void ReloopAnimations(CharacterMode mode)
 {
     SetCurrentAnimation(mode.ToString() + OrientationStrings[(int)CurrentOrientation]);
     if (AnimPlayer.IsDone())
     {
         AnimPlayer.Reset();
     }
 }
コード例 #13
0
ファイル: CharacterSprite.cs プロジェクト: kyroskoh/dwarfcorp
        public void ResetAnimations(CharacterMode mode)
        {
            List <Animation> animations = GetAnimations(mode);

            foreach (Animation a in animations)
            {
                a.Reset();
            }
        }
コード例 #14
0
ファイル: CharacterSprite.cs プロジェクト: kyroskoh/dwarfcorp
        public void PlayAnimations(CharacterMode mode)
        {
            List <Animation> animations = GetAnimations(mode);

            foreach (Animation a in animations)
            {
                a.IsPlaying = true;
            }
        }
コード例 #15
0
ファイル: Character.cs プロジェクト: xnum/hasuite
 public void DoWalk(int direction)
 {
     if (mode == CharacterMode.Fly)
     {
         return;
     }
     this.direction = direction;
     SetVelocity((int)(walkSpeed * direction));
     mode = CharacterMode.Walk;
 }
コード例 #16
0
        private IEnumerator switchModeCoroutine()
        {
            CharacterMode modeToSet = _mode == CharacterMode.SIMPLE ? CharacterMode.BATTLE : CharacterMode.SIMPLE;

            _mode = CharacterMode.CHANGING_MODE;
            _animator.ChangeMode(CharacterMode.CHANGING_MODE);
            yield return(new WaitForSeconds(_changeModeTimeSec));

            _mode = modeToSet;
            _animator.ChangeMode(modeToSet);
        }
コード例 #17
0
 public static Character GetCharacter(this IDbConnection ctx, CharacterMode mode, int playerId, string clientUUID)
 {
     if (mode == CharacterMode.AUTH)
     {
         return(ctx.SingleOrDefault <Character>(new { PlayerId = playerId }));
     }
     else
     {
         return(ctx.SingleOrDefault <Character>(new { UUID = clientUUID }));
     }
 }
 public static Character GetCharacter(this TContext ctx, CharacterMode mode, int userId, string clientUUID)
 {
     if (mode == CharacterMode.AUTH)
     {
         return ctx.Characters.SingleOrDefault(x => x.UserId == userId);
     }
     else
     {
         return ctx.Characters.SingleOrDefault(x => x.UUID == clientUUID);
     }
 }
コード例 #19
0
ファイル: CharacterSprite.cs プロジェクト: kyroskoh/dwarfcorp
 public static Animation CreateAnimation(CharacterMode mode,
                                         Orientation orient,
                                         SpriteSheet texture,
                                         float frameHz,
                                         int frameWidth,
                                         int frameHeight,
                                         int row,
                                         params int[] cols)
 {
     return(CreateAnimation(mode, orient, texture, frameHz, frameWidth, frameHeight, row, cols.ToList()));
 }
コード例 #20
0
 public static Character GetCharacter(this TContext ctx, CharacterMode mode, int userId, string clientUUID)
 {
     if (mode == CharacterMode.AUTH)
     {
         return(ctx.Characters.SingleOrDefault(x => x.UserId == userId));
     }
     else
     {
         return(ctx.Characters.SingleOrDefault(x => x.UUID == clientUUID));
     }
 }
コード例 #21
0
ファイル: CharacterSprite.cs プロジェクト: kyroskoh/dwarfcorp
        public void ReloopAnimations(CharacterMode mode)
        {
            List <Animation> animations = GetAnimations(mode);

            foreach (Animation a in animations)
            {
                if (a.IsDone())
                {
                    a.Reset();
                }
            }
        }
コード例 #22
0
 public static Character NewCharacter
 (
     TContext ctx,
     CharacterMode mode,
     string auth,
     string clientUUID,
     int health,
     int maxHealth,
     int mana,
     int maxMana,
     int spawnX,
     int spawnY,
     int hair,
     byte hairDye,
     bool[] hideVisual,
     byte difficulty,
     Microsoft.Xna.Framework.Color hairColor,
     Microsoft.Xna.Framework.Color skinColor,
     Microsoft.Xna.Framework.Color eyeColor,
     Microsoft.Xna.Framework.Color shirtColor,
     Microsoft.Xna.Framework.Color underShirtColor,
     Microsoft.Xna.Framework.Color pantsColor,
     Microsoft.Xna.Framework.Color shoeColor,
     int anglerQuests
 )
 {
     return(NewCharacter
            (
                ctx,
                mode,
                auth,
                clientUUID,
                health,
                maxHealth,
                mana,
                maxMana,
                spawnX,
                spawnY,
                hair,
                hairDye,
                DataEncoding.EncodeInteger(hideVisual),
                difficulty,
                DataEncoding.EncodeColor(hairColor),
                DataEncoding.EncodeColor(skinColor),
                DataEncoding.EncodeColor(eyeColor),
                DataEncoding.EncodeColor(shirtColor),
                DataEncoding.EncodeColor(underShirtColor),
                DataEncoding.EncodeColor(pantsColor),
                DataEncoding.EncodeColor(shoeColor),
                anglerQuests
            ));
 }
コード例 #23
0
 public static bool TryParse(string input, out CharacterMode mode)
 {
     mode = CharacterMode.NONE;
     try
     {
         mode = (CharacterMode)Enum.Parse(typeof(CharacterMode), input);
         return true;
     }
     catch
     {
         return false;
     }
 }
コード例 #24
0
ファイル: Character.cs プロジェクト: xnum/hasuite
 public void DoProne()
 {
     if (mode == CharacterMode.Fly)
     {
         return;
     }
     if (mode == CharacterMode.Walk)
     {
     }
     Velocity     = new Vector2();
     Acceleration = new Vector2();
     mode         = CharacterMode.Prone;
 }
コード例 #25
0
 public static bool TryParse(string input, out CharacterMode mode)
 {
     mode = CharacterMode.NONE;
     try
     {
         mode = (CharacterMode)Enum.Parse(typeof(CharacterMode), input);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #26
0
 public static Character NewCharacter(
     TContext ctx,
     CharacterMode mode,
     string auth,
     string clientUUID,
     int health,
     int maxHealth,
     int mana,
     int maxMana,
     int spawnX,
     int spawnY,
     int hair,
     byte hairDye,
     bool[] hideVisual,
     byte difficulty,
     Microsoft.Xna.Framework.Color hairColor,
     Microsoft.Xna.Framework.Color skinColor,
     Microsoft.Xna.Framework.Color eyeColor,
     Microsoft.Xna.Framework.Color shirtColor,
     Microsoft.Xna.Framework.Color underShirtColor,
     Microsoft.Xna.Framework.Color pantsColor,
     Microsoft.Xna.Framework.Color shoeColor, 
     int anglerQuests
 )
 {
     return NewCharacter
     (
         ctx,
         mode,
         auth,
         clientUUID,
         health,
         maxHealth,
         mana,
         maxMana,
         spawnX,
         spawnY,
         hair,
         hairDye,
         DataEncoding.EncodeInteger(hideVisual),
         difficulty,
         DataEncoding.EncodeColor(hairColor),
         DataEncoding.EncodeColor(skinColor),
         DataEncoding.EncodeColor(eyeColor),
         DataEncoding.EncodeColor(shirtColor),
         DataEncoding.EncodeColor(underShirtColor),
         DataEncoding.EncodeColor(pantsColor),
         DataEncoding.EncodeColor(shoeColor),
         anglerQuests
     );
 }
コード例 #27
0
        public static void Init(Entry plugin)
        {
            //            if (Storage.IsAvailable)
            //            {
            //                if (!Tables.CharacterTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC table does not exist and will now be created");
            //                    Tables.CharacterTable.Create();
            //                }
            //                if (!Tables.ItemTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC item table does not exist and will now be created");
            //                    Tables.ItemTable.Create();
            //                }
            //                if (!Tables.PlayerBuffTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC player buff table does not exist and will now be created");
            //                    Tables.PlayerBuffTable.Create();
            //                }
            //                if (!Tables.DefaultLoadoutTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC loadout table does not exist and will now be created");
            //                    Tables.DefaultLoadoutTable.Create();
            //                    Tables.DefaultLoadoutTable.PopulateDefaults(StartingOutInfo);
            //                }
            //            }

            //Player inventory,armor,dye common table


            CharacterMode characterMode;

            if (CharacterMode.TryParse(plugin.Config.SSC_CharacterMode, out characterMode))
            {
                Terraria.Main.ServerSideCharacter = characterMode != CharacterMode.NONE;
                CharacterManager.Mode             = characterMode;
                ProgramLog.Admin.Log("SSC mode: " + characterMode);

                plugin.Hook(HookPoints.ReceiveNetMessage, OnNetMessageReceived);
                //                        Hook(HookPoints.PlayerDataReceived, OnPlayerDataReceived);
            }
//            else
//                ProgramLog.Error.Log("Failed to parse line server-side-characters. No SSC will be used.");

            AllowGuestInfo = plugin.Config.SSC_AllowGuestInfo;
            SaveInterval   = plugin.Config.SSC_SaveInterval;

            //Default loadout table
            LoadConfig();
        }
コード例 #28
0
        public static void Init(Entry plugin)
        {
            //            if (Storage.IsAvailable)
            //            {
            //                if (!Tables.CharacterTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC table does not exist and will now be created");
            //                    Tables.CharacterTable.Create();
            //                }
            //                if (!Tables.ItemTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC item table does not exist and will now be created");
            //                    Tables.ItemTable.Create();
            //                }
            //                if (!Tables.PlayerBuffTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC player buff table does not exist and will now be created");
            //                    Tables.PlayerBuffTable.Create();
            //                }
            //                if (!Tables.DefaultLoadoutTable.Exists())
            //                {
            //                    ProgramLog.Admin.Log("SSC loadout table does not exist and will now be created");
            //                    Tables.DefaultLoadoutTable.Create();
            //                    Tables.DefaultLoadoutTable.PopulateDefaults(StartingOutInfo);
            //                }
            //            }

            //Player inventory,armor,dye common table


            CharacterMode characterMode;
            if (CharacterMode.TryParse(plugin.Config.SSC_CharacterMode, out characterMode))
            {
                Terraria.Main.ServerSideCharacter = characterMode != CharacterMode.NONE;
                CharacterManager.Mode = characterMode;
                ProgramLog.Admin.Log("SSC mode: " + characterMode);

                plugin.Hook(HookPoints.ReceiveNetMessage, OnNetMessageReceived);
                //                        Hook(HookPoints.PlayerDataReceived, OnPlayerDataReceived);
            }
//            else
//                ProgramLog.Error.Log("Failed to parse line server-side-characters. No SSC will be used.");

            AllowGuestInfo = plugin.Config.SSC_AllowGuestInfo;
            SaveInterval = plugin.Config.SSC_SaveInterval;

            //Default loadout table
            LoadConfig();
        }
コード例 #29
0
ファイル: Jumjaro.cs プロジェクト: teamdotsix/jumjaro
        // 문자 모드를 변경하고, 필요한 경우 모드 관련 문자를 추가한다
        private void ChangeMode(CharacterMode mode, StringBuilder sb)
        {
            if (_characterMode == mode)
            {
                return;
            }

            var prevMode = _characterMode;

            _characterMode = mode;

            if (_characterMode == CharacterMode.Number)
            {
                sb.Append('⠼');
            }
        }
コード例 #30
0
        void Start()
        {
            states.Add(PlayerData.State.IDLE, (PlayerState)(new PlayerState_Idle()));
            states.Add(PlayerData.State.PURSUIT, (PlayerState)(new PlayerState_Pursuit()));
            states.Add(PlayerData.State.ATTACKING, (PlayerState)(new PlayerState_Attacking()));
            states.Add(PlayerData.State.DEATH, (PlayerState)(new PlayerState_Death()));
            states.Add(PlayerData.State.FOLLOW, (PlayerState)(new PlayerState_Follow()));
            currentState = states [PlayerData.State.IDLE];

            if (playerData.characterID == GameManager.Instance.Player.currChar().playerData.characterID)
            {
                this.currentMode = CharacterMode.CONTROLLING;
            }

            currentState.Start(this);
        }
コード例 #31
0
        public EmployeeClass(EmployeeClassDef definition)
        {
            Name   = definition.Name;
            Levels = definition.Levels;
            foreach (string s in definition.Actions)
            {
                var value = Task.TaskCategory.None;
                if (Enum.TryParse(s, true, out value))
                {
                    Actions |= value;
                }
            }

            Animations = AnimationLibrary.LoadCompositeAnimationSet(definition.Animations, Name);
            Attacks    = definition.Attacks;
            AttackMode = definition.AttackMode;
        }
コード例 #32
0
ファイル: CharacterSprite.cs プロジェクト: kyroskoh/dwarfcorp
        public void AddAnimation(CharacterMode mode,
                                 Orientation orient,
                                 SpriteSheet texture,
                                 float frameHz,
                                 int frameWidth,
                                 int frameHeight,
                                 int row,
                                 params int[] cols)
        {
            List <int> ints = new List <int>();

            ints.AddRange(cols);
            Animation animation = CreateAnimation(mode, orient, texture, frameHz, frameWidth, frameHeight, row, ints);

            Animations[mode.ToString() + OrientationStrings[(int)orient]] = animation;
            animation.Play();
        }
コード例 #33
0
        public static int GetCharacterId(CharacterMode mode, string auth, string clientUUID)
        {
            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);
                return  user.Value.Id;
            }
            else if (mode != CharacterMode.UUID)
                return 0;

            using (var bl = Storage.GetBuilder(CharacterManager.SQLSafeName))
            {
                bl.SelectFrom(TableName, new string[] { ColumnNames.Id },
                    new WhereFilter(ColumnNames.UUID, clientUUID)
                );

                return Storage.ExecuteScalar<Int32>(bl);
            }
        }
コード例 #34
0
    // Start is called before the first frame update
    void Start()
    {
        Weapons = new List <GameObject>();
        Weapons.Add(PunchPrefab);

        collider      = GetComponent <Collider>();
        rigidbody     = GetComponent <Rigidbody>();
        audioSource   = GetComponent <AudioSource>();
        detectObjects = GetComponent <DetectObjects>();
        if (animator == null)
        {
            Debug.LogError("Defina o animator do personagem");
        }

        CharState = CharacterState.ALIVE;
        CharMode  = CharacterMode.WALKING_MODE;

        _start();
    }
コード例 #35
0
        public override void ChangeMode(CharacterMode newMode)
        {
            switch (newMode)
            {
            case CharacterMode.BATTLE:
                _animator.SetBool(IS_CHANGING_MODE, false);
                _animator.SetBool(IS_BATTLE_MODE, true);
                break;

            case CharacterMode.SIMPLE:
                _animator.SetBool(IS_CHANGING_MODE, false);
                _animator.SetBool(IS_BATTLE_MODE, false);
                break;

            case CharacterMode.CHANGING_MODE:
                _weaponAnimator.SwitchState();
                _animator.SetBool(IS_CHANGING_MODE, true);
                break;
            }
        }
コード例 #36
0
        public static int GetCharacterId(CharacterMode mode, string auth, string clientUUID)
        {
            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);
                return(user.Value.Id);
            }
            else if (mode != CharacterMode.UUID)
            {
                return(0);
            }

            using (var bl = Storage.GetBuilder(CharacterManager.SQLSafeName))
            {
                bl.SelectFrom(TableName, new string[] { ColumnNames.Id },
                              new WhereFilter(ColumnNames.UUID, clientUUID)
                              );

                return(Storage.ExecuteScalar <Int32>(bl));
            }
        }
コード例 #37
0
ファイル: Creature.cs プロジェクト: maroussil/dwarfcorp
        public void CheckNeighborhood(ChunkManager chunks, float dt)
        {
            Voxel voxelBelow = new Voxel();
            bool belowExists = chunks.ChunkData.GetVoxel(Physics.GlobalTransform.Translation - Vector3.UnitY * 0.8f, ref voxelBelow);
            Voxel voxelAbove = new Voxel();
            bool aboveExists = chunks.ChunkData.GetVoxel(Physics.GlobalTransform.Translation + Vector3.UnitY, ref voxelAbove);

            if (aboveExists)
            {
                IsHeadClear = voxelAbove.IsEmpty;
            }

            if (!Physics.IsInLiquid && CurrentCharacterMode == CharacterMode.Swimming)
            {
                CurrentCharacterMode = CharacterMode.Idle;
            }

            if(belowExists && Physics.IsInLiquid)
            {
                IsOnGround = false;
                CurrentCharacterMode = CharacterMode.Swimming;
            }
            else if(belowExists)
            {
                if(!voxelBelow.IsEmpty)
                {
                    IsOnGround = true;

                    if(CurrentCharacterMode != CharacterMode.Attacking) CurrentCharacterMode = CharacterMode.Idle;
                }
                else
                {
                    IsOnGround = false;
                    if(Physics.Velocity.Y > 0.05)
                    {
                        if (CurrentCharacterMode == CharacterMode.Walking || CurrentCharacterMode == CharacterMode.Idle || CurrentCharacterMode == CharacterMode.Falling)
                        {
                            CurrentCharacterMode = CharacterMode.Jumping;
                        }
                    }
                    else if(Physics.Velocity.Y < -0.05)
                    {
                        if (CurrentCharacterMode == CharacterMode.Walking || CurrentCharacterMode == CharacterMode.Idle || CurrentCharacterMode == CharacterMode.Jumping)
                        {
                            CurrentCharacterMode = CharacterMode.Falling;
                        }
                    }
                    else
                    {
                        if(CurrentCharacterMode == CharacterMode.Walking || CurrentCharacterMode == CharacterMode.Idle)
                        {
                            currentCharacterMode = CharacterMode.Idle;
                        }
                    }
                }
            }
            else
            {
                if(IsOnGround)
                {
                    IsOnGround = false;
                    if(CurrentCharacterMode != CharacterMode.Flying)
                    {
                        CurrentCharacterMode = Physics.Velocity.Y > 0 ? CharacterMode.Jumping : CharacterMode.Falling;
                    }
                }
            }

            if(Status.IsAsleep)
            {
                CurrentCharacterMode = CharacterMode.Sleeping;
            }
            else if (currentCharacterMode == CharacterMode.Sleeping)
            {
                CurrentCharacterMode = CharacterMode.Idle;
            }

            if (!Status.Energy.IsUnhappy())
            {
                Status.IsAsleep = false;
            }
        }
 public static Character GetCharacter(this IDbConnection ctx, CharacterMode mode, int playerId, string clientUUID)
 {
     if (mode == CharacterMode.AUTH)
     {
         return ctx.SingleOrDefault<Character>(new { PlayerId = playerId });
     }
     else
     {
         return ctx.SingleOrDefault<Character>(new { UUID = clientUUID });
     }
 }
コード例 #39
0
ファイル: Character.cs プロジェクト: johnnyeven/hasuite
 public void DoFly()
 {
     Acceleration = new Vector2(0, (float)gravityAcc);
     mode = CharacterMode.Fly;
 }
コード例 #40
0
ファイル: Character.cs プロジェクト: johnnyeven/hasuite
 public void DoProne()
 {
     if (mode == CharacterMode.Fly) return;
     if (mode == CharacterMode.Walk)
     {
     }
     Velocity = new Vector2();
     Acceleration = new Vector2();
     mode = CharacterMode.Prone;
 }
コード例 #41
0
ファイル: Character.cs プロジェクト: johnnyeven/hasuite
 public void DoWalk(int direction)
 {
     if (mode == CharacterMode.Fly) return;
     this.direction = direction;
     SetVelocity((int)(walkSpeed * direction));
     mode = CharacterMode.Walk;
 }
コード例 #42
0
        public static bool UpdateCharacter(
            CharacterMode mode,
            string auth,
            string clientUUID,
            int health,
            int maxHealth,
            int mana,
            int maxMana,
            int spawnX,
            int spawnY,
            int hair,
            byte hairDye,
            int hideVisual,
            byte difficulty,
            uint hairColor,
            uint skinColor,
            uint eyeColor,
            uint shirtColor,
            uint underShirtColor,
            uint pantsColor,
            uint shoeColor, 
            int anglerQuests
        )
        {
            int? userId = null;
            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);
                userId = user.Value.Id;
            }
            else if (mode != CharacterMode.UUID)
                return false;

            using (var bl = Storage.GetBuilder(CharacterManager.SQLSafeName))
            {
                if (mode == CharacterMode.AUTH)
                {
                    bl.Update(TableName, new DataParameter[]
                        {
                            new DataParameter(ColumnNames.Health, health),
                            new DataParameter(ColumnNames.MaxHealth, maxHealth),
                            new DataParameter(ColumnNames.Mana, mana),
                            new DataParameter(ColumnNames.MaxMana, maxMana),
                            new DataParameter(ColumnNames.SpawnX, spawnX),
                            new DataParameter(ColumnNames.SpawnY, spawnY),
                            new DataParameter(ColumnNames.Hair, hair),
                            new DataParameter(ColumnNames.HairDye, hairDye),
                            new DataParameter(ColumnNames.HideVisual, hideVisual),
                            new DataParameter(ColumnNames.Difficulty, difficulty),
                            new DataParameter(ColumnNames.HairColor, hairColor),
                            new DataParameter(ColumnNames.SkinColor, skinColor),
                            new DataParameter(ColumnNames.EyeColor, eyeColor),
                            new DataParameter(ColumnNames.ShirtColor, shirtColor),
                            new DataParameter(ColumnNames.UnderShirtColor, underShirtColor),
                            new DataParameter(ColumnNames.PantsColor, pantsColor),
                            new DataParameter(ColumnNames.ShoeColor, shoeColor),
                            new DataParameter(ColumnNames.AnglerQuests, anglerQuests)
                        },
                        new WhereFilter(ColumnNames.UserId, userId.Value)
                    );
                }
                else
                {
                    bl.Update(TableName, new DataParameter[]
                        {
                            new DataParameter(ColumnNames.Health, health),
                            new DataParameter(ColumnNames.MaxHealth, maxHealth),
                            new DataParameter(ColumnNames.Mana, mana),
                            new DataParameter(ColumnNames.MaxMana, maxMana),
                            new DataParameter(ColumnNames.SpawnX, spawnX),
                            new DataParameter(ColumnNames.SpawnY, spawnY),
                            new DataParameter(ColumnNames.Hair, hair),
                            new DataParameter(ColumnNames.HairDye, hairDye),
                            new DataParameter(ColumnNames.HideVisual, hideVisual),
                            new DataParameter(ColumnNames.Difficulty, difficulty),
                            new DataParameter(ColumnNames.HairColor, hairColor),
                            new DataParameter(ColumnNames.SkinColor, skinColor),
                            new DataParameter(ColumnNames.EyeColor, eyeColor),
                            new DataParameter(ColumnNames.ShirtColor, shirtColor),
                            new DataParameter(ColumnNames.UnderShirtColor, underShirtColor),
                            new DataParameter(ColumnNames.PantsColor, pantsColor),
                            new DataParameter(ColumnNames.ShoeColor, shoeColor),
                            new DataParameter(ColumnNames.AnglerQuests, anglerQuests)
                        },
                        new WhereFilter(ColumnNames.UUID, clientUUID)
                    );
                }

                return Storage.ExecuteNonQuery(bl) > 0;
            }
        }
コード例 #43
0
        public static int NewCharacter(
            CharacterMode mode,
            string auth,
            string clientUUID,
            int health,
            int maxHealth,
            int mana,
            int maxMana,
            int spawnX,
            int spawnY,
            int hair,
            byte hairDye,
            int hideVisual,
            byte difficulty,
            uint hairColor,
            uint skinColor,
            uint eyeColor,
            uint shirtColor,
            uint underShirtColor,
            uint pantsColor,
            uint shoeColor, 
            int anglerQuests
        )
        {
            int? userId = null;
            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);
                userId = user.Value.Id;
            }
            else if (mode != CharacterMode.UUID)
                return 0;

            using (var bl = Storage.GetBuilder(CharacterManager.SQLSafeName))
            {
                bl.InsertInto(TableName,
                    new DataParameter(ColumnNames.UserId, userId),
                    new DataParameter(ColumnNames.UUID, clientUUID),
                    new DataParameter(ColumnNames.Health, health),
                    new DataParameter(ColumnNames.MaxHealth, maxHealth),
                    new DataParameter(ColumnNames.Mana, mana),
                    new DataParameter(ColumnNames.MaxMana, maxMana),
                    new DataParameter(ColumnNames.SpawnX, spawnX),
                    new DataParameter(ColumnNames.SpawnY, spawnY),
                    new DataParameter(ColumnNames.Hair, hair),
                    new DataParameter(ColumnNames.HairDye, hairDye),
                    new DataParameter(ColumnNames.HideVisual, hideVisual),
                    new DataParameter(ColumnNames.Difficulty, difficulty),
                    new DataParameter(ColumnNames.HairColor, hairColor),
                    new DataParameter(ColumnNames.SkinColor, skinColor),
                    new DataParameter(ColumnNames.EyeColor, eyeColor),
                    new DataParameter(ColumnNames.ShirtColor, shirtColor),
                    new DataParameter(ColumnNames.UnderShirtColor, underShirtColor),
                    new DataParameter(ColumnNames.PantsColor, pantsColor),
                    new DataParameter(ColumnNames.ShoeColor, shoeColor),
                    new DataParameter(ColumnNames.AnglerQuests, anglerQuests)
                );

                return (int)Storage.ExecuteInsert(bl); //Get the new ID
            }
        }
コード例 #44
0
ファイル: Character.cs プロジェクト: johnnyeven/hasuite
        //measurement units are second and pixel
        public void ProcessPhysics()
        {
            double timeDiff = (Environment.TickCount - lastProcessTimeStamp) / 1000d;
            if (timeDiff == 0) return;
            if (mode == CharacterMode.Prone) goto end;
            int x_threshold = (int)(timeDiff * Velocity.X + (Acceleration.X / 2) * timeDiff * timeDiff);//x = vt + 0.5at^2
            int y_threshold = (int)(timeDiff * Velocity.Y + (Acceleration.Y / 2) * timeDiff * timeDiff);
            Velocity.X += (int)(Acceleration.X * timeDiff); //v = at
            Velocity.Y += (int)(Acceleration.Y * timeDiff);
            if (Velocity.Y > fallSpeed) Velocity.Y = (int)fallSpeed;

            if (mode != CharacterMode.Fly)
            {
                if (direction == 1 && x + x_threshold > foothold.x2)
                {
                    if (foothold.next != 0)
                    {
                        Foothold = foothold.next;
                        x = foothold.x1;
                        y = foothold.y1;
                        SetVelocity((int)Velocity.X);
                    }
                }
                else if (direction == -1 && x - x_threshold < foothold.x1)
                {
                    if (foothold.prev != 0)
                    {
                        Foothold = foothold.prev;
                        x = foothold.x2;
                        y = foothold.y2;
                        SetVelocity((int)Velocity.X);
                    }
                }
                else
                {
                    y += y_threshold;
                    x += x_threshold;
                }
                if (foothold.num == 0)
                    DoProne();
            }
            else
            {
                if (Velocity.Y > 0)
                foreach (DictionaryEntry fhEntry in MapSimulator.footholds)
                {
                    Foothold fh = (Foothold)fhEntry.Value;
                    if (fh.x1 < x + x_threshold && fh.x2 > x + x_threshold)
                    {
                        int slope = (fh.y2 - fh.y1) / (fh.x2 - fh.x1);
                        int yPos = fh.y1 + slope * ((x + x_threshold) - fh.x1);
                        if (y < yPos && y + y_threshold >= yPos)
                        {
                            y = yPos;
                            x += x_threshold;
                            foothold = fh;
                            footholdNum = fh.num;
                            mode = CharacterMode.Prone;
                            goto end;
                        }
                    }
                }
                y += y_threshold;
                if (y_threshold < 0)
                {
                }
                x += x_threshold;
            }
            end:
            lastProcessTimeStamp = Environment.TickCount;
        }
コード例 #45
0
        public static Character NewCharacter(
            TContext ctx,
            CharacterMode mode,
            string auth,
            string clientUUID,
            int health,
            int maxHealth,
            int mana,
            int maxMana,
            int spawnX,
            int spawnY,
            int hair,
            byte hairDye,
            int hideVisual,
            byte difficulty,
            uint hairColor,
            uint skinColor,
            uint eyeColor,
            uint shirtColor,
            uint underShirtColor,
            uint pantsColor,
            uint shoeColor, 
            int anglerQuests
        )
        {
            int? userId = null;
            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);
                userId = user.Id;
            }
            else if (mode != CharacterMode.UUID)
                return null;

            Character chr = new Character()
            {
                UserId = userId,
                UUID = clientUUID,
                Health = health,
                MaxHealth = maxHealth,
                Mana = mana,
                MaxMana = maxMana,
                SpawnX = spawnX,
                SpawnY = spawnY,
                Hair = hair,
                HairDye = hairDye,
                HideVisual = hideVisual,
                Difficulty = difficulty,
                HairColor = hairColor,
                SkinColor = skinColor,
                EyeColor = eyeColor,
                ShirtColor = shirtColor,
                UnderShirtColor = underShirtColor,
                PantsColor = pantsColor,
                ShoeColor = shoeColor,
                AnglerQuests = anglerQuests
            };
            ctx.Characters.Add(chr);

            ctx.SaveChanges();

            return chr;
        }
コード例 #46
0
        public static Character UpdateCharacter(
            TContext ctx,
            CharacterMode mode,
            string auth,
            string clientUUID,
            int health,
            int maxHealth,
            int mana,
            int maxMana,
            int spawnX,
            int spawnY,
            int hair,
            byte hairDye,
            int hideVisual,
            byte difficulty,
            uint hairColor,
            uint skinColor,
            uint eyeColor,
            uint shirtColor,
            uint underShirtColor,
            uint pantsColor,
            uint shoeColor, 
            int anglerQuests
        )
        {
            int? userId = null;
            if (mode == CharacterMode.AUTH)
            {
                var user = AuthenticatedUsers.GetUser(auth);
                userId = user.Id;
            }
            else if (mode != CharacterMode.UUID)
                return null;

            Character chr;
            if (mode == CharacterMode.AUTH)
            {
                chr = ctx.Characters.Single(x => x.UserId == userId.Value);
            }
            else
            {
                chr = ctx.Characters.Single(x => x.UUID == clientUUID);
            }

            chr.Health = health;
            chr.MaxHealth = maxHealth;
            chr.Mana = mana;
            chr.MaxMana = maxMana;
            chr.SpawnX = spawnX;
            chr.SpawnY = spawnY;
            chr.Hair = hair;
            chr.HairDye = hairDye;
            chr.HideVisual = hideVisual;
            chr.Difficulty = difficulty;
            chr.HairColor = hairColor;
            chr.SkinColor = skinColor;
            chr.EyeColor = eyeColor;
            chr.ShirtColor = shirtColor;
            chr.UnderShirtColor = underShirtColor;
            chr.PantsColor = pantsColor;
            chr.ShoeColor = shoeColor;
            chr.AnglerQuests = anglerQuests;

            ctx.SaveChanges();

            return chr;
        }