Example #1
0
        public override void DoAction(IEventArgs args)
        {
            int realType = args.GetInt(type);
            int dis      = args.GetInt(distance);

            int i = 1;

            UnitPosition up     = pos.Select(args);
            Vector3      target = new Vector3(up.GetX(), up.GetY(), up.GetZ());

            foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(args.GameContext.session.commonSession.RoomInfo.MapId).IDPints)
            {
                if (p.ID == realType)
                {
                    foreach (MapConfigPoints.SavedPointData v in p.points)
                    {
                        if (IsNear(v.pos, target, dis))
                        {
                            TriggerArgs ta = new TriggerArgs();
                            ta.AddPara(new FloatPara("x", v.pos.x));
                            ta.AddPara(new FloatPara("y", v.pos.y));
                            ta.AddPara(new FloatPara("z", v.pos.z));
                            ta.AddPara(new FloatPara("index", i++));

                            args.Act(action, ta);
                        }
                    }
                }
            }
        }
Example #2
0
 private void HandleRemoveBuf(IEventArgs args, PlayerEntity player, int oldBufs, int newBufs)
 {
     for (int i = 1; i < bufs.Length; i++)
     {
         if ((newBufs & (1 << i)) == 0 && (oldBufs & (1 << i)) > 0)
         {
             if (bufs[i] != null && bufs[i].endAction != null)
             {
                 args.Act(bufs[i].endAction, new TempUnit("current", (FreeData)player.freeData.FreeData));
             }
         }
     }
 }
Example #3
0
 private void HandleAddBuf(IEventArgs args, PlayerEntity player, int oldBufs, int newBufs)
 {
     for (int i = 1; i < bufs.Length; i++)
     {
         if ((newBufs & (1 << i)) > 0 && (oldBufs & (1 << i)) == 0)
         {
             if (bufs[i] != null && bufs[i].startAction != null)
             {
                 if (bufs[i].action != null)
                 {
                     bufs[i].action.Reset(args);
                 }
                 args.Act(bufs[i].startAction, new TempUnit("current", (FreeData)player.freeData.FreeData));
             }
         }
     }
 }
        public override void DoAction(IEventArgs args)
        {
            var msg = GameOverMessage.Allocate();

            msg.HallRoomId = args.GameContext.session.commonSession.RoomInfo.HallRoomId;

            FreeGameRule rule = (FreeGameRule)args.Rule;

            foreach (PlayerEntity player in args.GameContext.player.GetInitializedPlayerEntities())
            {
                SimpleParable  sp    = new SimpleParable();
                SimpleParaList paras = new SimpleParaList();
                sp.SetList(paras);

                var gameOverPlayer = GameOverPlayer.Allocate();

                paras.AddFields(new ObjectFields(gameOverPlayer));
                gameOverPlayer.Id = player.playerInfo.PlayerId;

                args.Act(action, new TempUnit[] { new TempUnit("basic", sp) });
            }
        }
Example #5
0
        private bool CheckHit(IEventArgs args, FreeEntityData data, Vector3 fromV, Vector3 toV, float dis)
        {
            Ray r = new Ray(fromV, new Vector3(toV.x - fromV.x, toV.y - fromV.y, toV.z - fromV.z));

            RaycastHit[] hits = Physics.RaycastAll(r, dis);

            if (hits.Length > 0)
            {
                PlayerEntity player = args.GameContext.player.GetEntityWithEntityKey(new Core.EntityComponent.EntityKey(data.CreatorId, (short)EEntityType.Player));

                int      team   = 0;
                FreeData source = null;
                if (player != null)
                {
                    team   = player.playerInfo.Camp;
                    source = (FreeData)player.freeData.FreeData;
                }

                foreach (RaycastHit hit in hits)
                {
                    var comp = hit.collider.transform.gameObject.GetComponent <EntityReference>();
                    if (comp != null)
                    {
                        PlayerEntity hitPlayer = args.GameContext.player.GetEntityWithEntityKey(comp.EntityKey);

                        if (hitPlayer != null && hitPlayer != player && !hitPlayer.gamePlay.IsDead())
                        {
                            bool sameTeam = hitPlayer.playerInfo.Camp == team;
                            switch ((HitType)hitType)
                            {
                            case HitType.HitAll:
                                args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData),
                                         new TempUnit("pos", new ObjectUnit(hit.point)));
                                break;

                            case HitType.HitEnemy:
                                if (!sameTeam)
                                {
                                    args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData),
                                             new TempUnit("pos", new ObjectUnit(hit.point)));
                                }
                                break;

                            case HitType.HitAnyGone:
                                args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData),
                                         new TempUnit("pos", new ObjectUnit(hit.point)));
                                return(true);

                            case HitType.HitEnemyGone:
                                if (!sameTeam)
                                {
                                    args.Act(hitAction, new TempUnit("source", source), new TempUnit("target", (FreeData)hitPlayer.freeData.FreeData),
                                             new TempUnit("pos", new ObjectUnit(hit.point)));
                                    return(true);
                                }
                                break;
                            }
                        }
                        Debug.LogFormat(hit.collider.gameObject.GetInstanceID().ToString() + " of " + hits.Length);
                    }
                }
            }

            return(false);
        }