Ejemplo n.º 1
0
 /// <summary>
 /// 'Volplane.OnDisconnect()' method from the Volplane framework
 /// OnDisconnect is called when an AirConsole player left the session.
 /// </summary>
 /// <param name="player">The player object of the disconnected device.</param>
 private void OnDisconnect(VPlayer player)
 {
     // If the player was active while connected -> stop this game.
     // Meaning this player was actually playing.
     if (player.IsActive)
     {
         StopGame();
     }
 }
Ejemplo n.º 2
0
    private void RandomizeSwipes(VPlayer player)
    {
        HideAll(player, swipes);
        int    i       = Random.Range(0, swipesAvailable.Count);
        string element = swipesAvailable[i];

        swipesUsed.Add(element);
        swipesAvailable.Remove(element);
        player.ShowElement(element);
    }
Ejemplo n.º 3
0
        internal static void ApplyAllBuffs()
        {
            // Add cached projectile buffs to their owner
            for (int i = 0; i < Main.projectile.Length; i++)
            {
                if (Main.projectile[i].active && Main.projectile[i].minion)
                {
                    ProjCache.GetData(Main.projectile[i]).ApplyBuffs();
                }
            }

            // Then activate both npcs and players together
            for (int i = 0; i < Main.npc.Length; i++)
            {
                if (i < 255 && Main.player[i].active)
                {
                    int pid = VPlayer.GetData(Main.player[i]).GlobalID;
                    if (AllPlayerBuffers.TryGetValue(pid, out Dictionary <string, int> pbuffer) &&
                        AllPlayerBuffs.TryGetValue(pid, out Dictionary <string, int> playerbuffs))
                    {
                        playerbuffs.Clear();
                        playerbuffs.AddRange(pbuffer);
                        pbuffer.Clear();

                        if (!Main.player[i].dead && !Main.player[i].ghost)
                        {
                            foreach ((string buff, int duration) in playerbuffs)
                            {
                                int vanilla = TranslateVanilla(buff);
                                Main.player[i].AddBuff(vanilla != -1 ? vanilla : TranslateVitri(buff).Type, duration);
                            }
                        }
                    }
                }

                if (Main.npc[i].active)
                {
                    int nid = VNPC.GetData(Main.npc[i]).GlobalID;
                    if (AllNPCBuffers.TryGetValue(nid, out Dictionary <string, int> nbuffer) &&
                        AllNPCBuffs.TryGetValue(nid, out Dictionary <string, int> npcbuffs))
                    {
                        npcbuffs.Clear();
                        npcbuffs.AddRange(nbuffer);
                        nbuffer.Clear();

                        foreach ((string buff, int duration) in npcbuffs)
                        {
                            int vanilla = TranslateVanilla(buff);
                            Main.npc[i].AddBuff(vanilla != -1 ? vanilla : TranslateVitri(buff).Type, duration);
                        }
                    }
                }
            }
        }
 public void HideAll(VPlayer player, List <string> elementType)
 {
     foreach (string item in elementType)
     {
         player.ChangeElementProperties(item, hide);
     }
     foreach (string item in elementType)
     {
         player.ChangeElementProperties(item, hide);
     }
 }
Ejemplo n.º 5
0
        public override void OnConsumeAmmo(VPlayer player, Item weapon, Item ammo)
        {
            // make it so the player chooses which ammo types to pick from by scanning their inventory and adding ammo items to a list
            // probably do this in Shoot
            Type[]      types       = Main.instance.GetType().Assembly.GetTypes();
            FieldInfo[] projectiles = null;

            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].Name.IsSimilarTo("projectileid"))
                {
                    projectiles = types[i].GetFields();
                    break;
                }
            }

            if (projectiles == null)
            {
                return;
            }

            List <FieldInfo> fields = new List <FieldInfo>();

            for (int i = 0; i < projectiles.Length; i++)
            {
                FieldInfo projInfo = projectiles[i];
                bool Contains(string val)
                {
                    return(projInfo.Name.Contains(val));
                }

                if (ammo.ammo == AmmoID.Arrow &&
                    Contains("Arrow") &&
                    !Contains("Hostile") &&
                    !projInfo.Name.IsSimilarTo("FlamingArrow"))
                {
                    fields.Add(projInfo);
                }
                else if (ammo.ammo == AmmoID.Bullet &&
                         Contains("Bullet"))
                {
                    fields.Add(projInfo);
                }
                else if (ammo.ammo == AmmoID.Rocket &&
                         Contains("Rocket"))
                {
                    fields.Add(projInfo);
                }
            }

            FieldInfo selected = fields[Main.rand.Next(0, fields.Count)];

            ammo.shoot = (int)selected.GetValue(Main.instance);
        }
Ejemplo n.º 6
0
        public override void HandlerPointerUp(IInteractive interactive, InputData data)
        {
            VPlayer player = VPlayer.instance;

            player.SetTracingTarget(null);

            if (interactive is VBattle)
            {
                Vector3 point;
                if (this.GetGroundHitPoint(out point))
                {
                    if (this._decal != null)
                    {
                        this._decal.markToDestroy = true;
                        this._decal = null;
                    }

                    Effect e = this.owner.battle.CreateEffect("e152");
                    point.y    = 0.02f;
                    e.position = point;

                    this.MovePlayer(point);
                }
            }
            else
            {
                if (interactive is VBio bio && !bio.isDead)
                {
                    if (VEntityUtils.IsAllied(player, bio) &&
                        bio != player &&
                        player.CanMove())
                    {
                        FrameActionManager.SetFrameAction(new _DTO_action_info(VPlayer.instance.rid, ( byte )FrameActionType.Track, bio.rid));
                    }
                    else
                    {
                        Vector3 position = data.currentRaycast.point;
                        position.y = 0f;
                        Skill skill = player.commonSkill;
                        if (player.CanUseSkill(skill) &&
                            VEntityUtils.CanAttack(player, bio, skill.campType, skill.targetFlag))
                        {
                            player.SetTracingTarget(bio);
                            //普攻
                            FrameActionManager.SetFrameAction(new _DTO_action_info(player.rid, ( byte )FrameActionType.UseSkill, skill.id,
                                                                                   player.rid, bio.rid, position.x, position.y, position.z));
                        }
                        else
                        {
                            UIEvent.SkillUseFailed(player, skill, bio);
                        }
                    }
                }
Ejemplo n.º 7
0
        private void OpenVideoSource(IVideoSource source)
        {
            if (MainWindow.FormHostChildControl.Child == null)
            {
                MainWindow.FormHostChildControl.Child = VPlayer;
            }

            if (MjpegSource == null || string.IsNullOrEmpty(source.Source))
            {
                return;
            }

            VPlayer.VideoSource = source;
            VPlayer.Start();
        }
Ejemplo n.º 8
0
        public override bool PreHurt(VPlayer player, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
        {
            if (player.player.statLife - (damage * (crit ? 2 : 1)) <= 0)
            {
                player.player.statLife = player.player.statLifeMax2 + damage;
                player.player.AddBuff("angeldebuff", 108000);

                if (Main.netMode != NetmodeID.SinglePlayer)
                {
                    NetMessage.SendData(MessageID.PlayerHealth, -1, -1, null, player.player.whoAmI, player.player.statLife, player.player.statLifeMax, player.player.statLifeMax2);
                }
            }

            return(true);
        }
Ejemplo n.º 9
0
        public static bool HasBuff(this Player player, string buffname)
        {
            buffname = buffname.ToLower();
            int id = VPlayer.GetData(player).GlobalID;

            if (AllPlayerBuffs.TryGetValue(id, out Dictionary <string, int> map))
            {
                return(map.ContainsKey(buffname));
            }

            if (AllPlayerBuffers.TryGetValue(id, out Dictionary <string, int> map2))
            {
                return(map2.ContainsKey(buffname));
            }

            return(false);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 'Volplane.OnHero()' method from the Volplane framework
        /// OnHero is called when a player becomes AirConsole Hero or an AirConsole Hero player connects.
        /// </summary>
        /// <param name="player">The player object of the AirConsole Hero device.</param>
        private void OnHero(VPlayer player)
        {
            if (!lobbyActive)
            {
                return;
            }

            // It could be that the game master has now changed
            if (GetMasterId() == player.PlayerId)
            {
                // If this player is the new master and it is not active (just spectating)
                // kick an active player and take its slot instead!
                if (!player.IsActive)
                {
                    KickPlayer(GetAllActivePlayers().Last().PlayerId);
                }
            }
        }
    private void RandomizeSwipes(VPlayer player)
    {
        // First Swipe
        int    i       = Random.Range(0, swipesAvailable.Count);
        string element = swipesAvailable[i];

        swipesUsed.Add(element);
        swipesAvailable.Remove(element);
        player.ShowElement("Bottom_Left");
        player.ChangeElementText("Bottom_Left", element);

        // Second Swipe
        i       = Random.Range(0, swipesAvailable.Count);
        element = swipesAvailable[i];
        swipesUsed.Add(element);
        swipesAvailable.Remove(element);
        player.ShowElement("Bottom_Right");
        player.ChangeElementText("Bottom_Right", element);
    }
Ejemplo n.º 12
0
    private void RandomizeButtons(VPlayer player)
    {
        // First Button
        int    i       = Random.Range(0, buttonsAvailable.Count);
        string element = buttonsAvailable[i];

        buttonsUsed.Add(element);
        buttonsAvailable.Remove(element);
        player.ShowElement(element);
        // Move button to correct spot.

        // Second Button
        i       = Random.Range(0, buttonsAvailable.Count);
        element = buttonsAvailable[i];
        buttonsUsed.Add(element);
        buttonsAvailable.Remove(element);
        player.ShowElement(element);
        // Move button to correct spot.
    }
    private void RandomizeButtons(VPlayer player)
    {
        // First Button
        int    i       = Random.Range(0, buttonsAvailable.Count);
        string btnText = buttonsAvailable[i];

        buttonsUsed.Add(btnText);
        buttonsAvailable.Remove(btnText);
        player.ShowElement("Top_Left");
        player.ChangeElementText("Top_Left", btnText);
        // Move button to correct spot.

        // Second Button
        i       = Random.Range(0, buttonsAvailable.Count);
        btnText = buttonsAvailable[i];
        buttonsUsed.Add(btnText);
        buttonsAvailable.Remove(btnText);
        player.ShowElement("Top_Right");
        player.ChangeElementText("Top_Right", btnText);
        // Move button to correct spot.
    }
Ejemplo n.º 14
0
        /// <summary>
        /// 'Volplane.OnConnect()' method from the Volplane framework
        /// OnConnect is called when a new AirConsole player joins the session.
        /// </summary>
        /// <param name="player">The player object of the connected device.</param>
        private void OnConnect(VPlayer player)
        {
            // Set player inactive if it is active and game not started yet
            if (player.IsActive && !gameStarted)
            {
                player.SetActive(false);
            }

            // You will not receive any input from inactive players.
            // By default every new connected player will be set as inactive, with the exception
            // of the game master. The game master (AirConsoles master device) is the one who is able
            // to navigate on the AirConsole platform.

            // Display a text on the controller indicating which racket this player will play
            if (player.PlayerId == 0)
            {
                player.ChangeElementText("infoText", "You are on the left...");
            }
            else
            {
                player.ChangeElementText("infoText", "You are on the right...");
            }

            // In this example, the player with the id 0 will play the left racket, the player
            // with the id 1 will play the right one.
            // Remember: The game master may not necessarily have an id of 0. The player id are ordered
            // by whichever device connects first. However player ids can be hardcoded. For example if
            // the game master has the player id 3 and suddenly looses connection, on a rejoin, the
            // controller will be reassigned to this id and player object.

            // Update pause text with the current player count
            pauseText.text = string.Format("{0} Players connected\nWaiting for more players...", PlayerCount);

            // When two players are connected and game has not started yet
            // -> let's go
            if ((PlayerCount == 2) && !gameStarted)
            {
                StartGame();
            }
        }
Ejemplo n.º 15
0
        public override void PostUpdate(VPlayer player)
        {
            player.player.MakeImmuneTo("regenbuff");

            for (int i = 0; i < Main.npc.Length; i++)
            {
                if (i < 255)
                {
                    Player member = Main.player[i];
                    if (member.active && !member.dead && !member.ghost && member.team == player.player.team && player.player.Distance(member.Center) <= Main.spawnTileX / 2)
                    {
                        Main.player[i].AddBuff("regenbuff");
                    }
                }

                NPC friend = Main.npc[i];
                if (friend.active && (friend.friendly || friend.townNPC) && player.player.Distance(friend.Center) <= Main.spawnTileX / 2)
                {
                    Main.player[i].AddBuff("regenbuff");
                }
            }
        }
Ejemplo n.º 16
0
        public override void PostUpdate(VPlayer player)
        {
            for (int i = 0; i < Main.npc.Length; i++)
            {
                if (i < 255)
                {
                    Player a = Main.player[i];
                    if (a.active && !a.dead && !a.ghost && (a.team == (int)Team.None || a.team != player.player.team) && a.whoAmI != player.player.whoAmI && Vector2.Distance(player.player.Center, a.Center) <= Main.spawnTileY / 1.5f)
                    {
                        if (Main.rand.NextFloat() <= 0.05f / 60f)
                        {
                            a.buffImmune[BuffID.Frozen] = false;
                            a.AddBuff(BuffID.Frozen, 300);
                        }
                        else
                        {
                            a.buffImmune[BuffID.Chilled] = false;
                            a.AddBuff(BuffID.Chilled, 2);
                        }
                    }
                }

                NPC npc = Main.npc[i];
                if (npc.active && !npc.friendly && !npc.townNPC && Vector2.Distance(player.player.Center, npc.Center) <= Main.spawnTileY / 1.5f)
                {
                    if (Main.rand.NextFloat() <= 0.05f / 120f)
                    {
                        npc.buffImmune[BuffID.Frozen] = false;
                        npc.AddBuff(BuffID.Frozen, 300);
                    }
                    else
                    {
                        npc.buffImmune[BuffID.Chilled] = false;
                        npc.AddBuff(BuffID.Chilled, 2);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public override void PostUpdate(VPlayer player)
        {
            player.player.aggro -= 50;

            for (int i = 0; i < Main.npc.Length; i++)
            {
                if (i < 255)
                {
                    Player a = Main.player[i];
                    if (a.active && !a.dead && !a.ghost && a.team != player.player.team && a.whoAmI != player.player.whoAmI && Vector2.Distance(player.player.Center, a.Center) <= Main.spawnTileY / 1.5)
                    {
                        a.AddBuff(BuffID.Darkness, 2);
                    }
                }

                NPC npc = Main.npc[i];
                if (npc.active && npc.damage > 0 && !npc.friendly && !npc.townNPC && npc.type != NPCID.TargetDummy && Vector2.Distance(player.player.Center, npc.Center) <= Main.spawnTileY / 1.5)
                {
                    npc.buffImmune[BuffID.Darkness] = false;
                    npc.AddBuff(BuffID.Darkness, 2);
                }
            }
        }
Ejemplo n.º 18
0
        public override void ModifyWeaponDamage(VPlayer player, Item item, ref float add, ref float mult, ref float flat)
        {
            if (item.IsTool())
            {
                add               *= 1.5f;
                mult              *= 1.5f;
                item.useTime      /= 2;
                item.useAnimation /= 2;
                item.autoReuse     = true;
                item.useTurn       = true;
            }
            else if (item.IsWeapon())
            {
                item.autoReuse     = false;
                item.useTurn       = false;
                item.useTime      *= 2;
                item.useAnimation *= 2;
                add  /= 1.5f;
                mult /= 1.5f;
            }

            //flat += 10f;
            //mult += 5f;
        }
Ejemplo n.º 19
0
 public virtual void ModifyHitNPC(VPlayer player, NPC target, Item item, ref int damage, ref float knockback, ref bool crit)
 {
 }
Ejemplo n.º 20
0
        public override void UpdateEquips(VPlayer player, ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
        {
            if (player.player.dash > 0)
            {
                player.player.dash = -1;
            }

            if (player.player.dashTime > 0)
            {
                player.player.dashTime--;
            }

            if (player.player.dashTime < 0)
            {
                player.player.dashTime++;
            }

            if (dashTimer > 0)
            {
                dashTimer--;
            }

            if (dashTimer < 0)
            {
                dashTimer++;
            }

            if (player.player.dashDelay > 0)
            {
                player.player.dashDelay--;
                return;
            }

            bool flag = false;
            int  lor  = 0;
            int  uod  = 0;

            if (player.player.controlLeft && player.player.releaseLeft)
            {
                if (player.player.dashTime < 0)
                {
                    lor  = -1;
                    flag = true;
                    player.player.dashTime = 0;
                }
                else
                {
                    player.player.dashTime = -15;
                }
            }
            else if (player.player.controlRight && player.player.releaseRight)
            {
                if (player.player.dashTime > 0)
                {
                    lor  = 1;
                    flag = true;
                    player.player.dashTime = 0;
                }
                else
                {
                    player.player.dashTime = 15;
                }
            }

            if (player.player.controlUp && player.player.releaseUp && player.player.grapCount == 0)
            {
                if (dashTimer > 0)
                {
                    uod       = -1;
                    flag      = true;
                    dashTimer = 0;
                }
                else
                {
                    dashTimer = 15;
                }
            }
            else if (player.player.controlDown && player.player.releaseDown)
            {
                if (dashTimer < 0)
                {
                    uod       = 1;
                    flag      = true;
                    dashTimer = 0;
                }
                else
                {
                    dashTimer = -15;
                }
            }

            if (flag)
            {
                Vector2 direction = new Vector2(240 * lor, 240 * uod);
                Vector2 position  = player.player.position;
                int     width     = player.player.width;
                int     height    = player.player.height;
                int     i         = 0;
                while (i <= 240 && !(direction == default))
                {
                    for (int val = -5; val < 6; val++)
                    {
                        Vector2 destination = position + new Vector2(direction.X, direction.Y - val * 16);
                        if (!Collision.SolidCollision(destination, width, height) && Collision.SolidCollision(destination + new Vector2(0f, 16f), width, height))
                        {
                            direction = new Vector2(direction.X, direction.Y - val * 16);
                            break;
                        }
                    }
                    if (!Collision.SolidCollision(position + direction, width, height))
                    {
                        break;
                    }
                    if (direction.X > 0f)
                    {
                        direction.X -= 1f;
                    }
                    if (direction.X < 0f)
                    {
                        direction.X += 1f;
                    }
                    if (direction.Y > 0f)
                    {
                        direction.Y -= 1f;
                    }
                    if (direction.Y < 0f)
                    {
                        direction.Y += 1f;
                    }
                    i++;
                }
                float ox = position.X;
                float oy = position.Y;
                player.player.grapCount = 0;
                player.player.BetterTeleport(player.player.position + direction, 0);

                if (Main.netMode != NetmodeID.Server)
                {
                    if (uod == -1 && lor == 0 && direction.X == 0f)
                    {
                        player.player.position.X = ox;
                    }

                    if (uod == 0 && lor != 0 && direction.Y == 0f)
                    {
                        player.player.position.Y = oy;
                    }

                    player.player.dashDelay = 120;
                }
            }
        }
Ejemplo n.º 21
0
 public override void ModifyWeaponDamage(VPlayer player, Item item, ref float add, ref float mult, ref float flat)
 {
     item.useTime      /= 2;
     item.useAnimation /= 2;
 }
Ejemplo n.º 22
0
 // Update methods
 public virtual void ResetEffects(VPlayer player)
 {
 }
Ejemplo n.º 23
0
 public virtual void ModifyWeaponDamage(VPlayer player, Item item, ref float add, ref float mult, ref float flat)
 {
 }
Ejemplo n.º 24
0
 public virtual void ModifyHitPvpWithProj(VPlayer player, Player target, Projectile proj, ref int damage, ref bool crit)
 {
 }
Ejemplo n.º 25
0
 public override bool ConsumeAmmo(VPlayer player, Item weapon, Item ammo)
 {
     return(base.ConsumeAmmo(player, weapon, ammo));
 }
Ejemplo n.º 26
0
 public virtual void ModifyHitByProjectile(VPlayer player, Projectile proj, ref int damage, ref bool crit)
 {
 }
Ejemplo n.º 27
0
 protected override void OnBindingContextChanged()
 {
     base.OnBindingContextChanged();
     VPlayer.SetData(ContentType, Source);
 }
Ejemplo n.º 28
0
 public virtual void ModifyHitNPCWithProj(VPlayer player, NPC target, Projectile proj, ref int damage, ref float knockback, ref bool crit, ref int direction)
 {
 }
Ejemplo n.º 29
0
 public virtual void ModifyHitByPvp(VPlayer vp, Player player, ref int damage, ref bool crit)
 {
 }
Ejemplo n.º 30
0
 public virtual void ModifyHitPvp(VPlayer player, Player target, Item item, ref int damage, ref bool crit)
 {
 }