コード例 #1
0
    public void ShootLaser(SimpleRay2D ray, PlayerPawn owner)
    {
        List <PlayerPawn> playersHit = CastRay(ray);

        Network.Log("Laser hits " + playersHit.Count + " players.");
        float laserPower       = owner.GetLaserDamage();
        float powerAccumulator = 0.0f;

        for (int i = 0; i < playersHit.Count; ++i)
        {
            if (playersHit[i] == owner)
            {
                continue;
            }

            powerAccumulator += playersHit[i].ReceiveDamage(laserPower);
        }

        owner.AddPower(powerAccumulator);

        ShotEvent se = new ShotEvent();

        se.m_direction       = ray.direction;
        se.m_point           = owner.Position;
        se.m_who             = owner.Id;
        se.m_reliableEventId = Network.Server.GetNewReliableEventId();
        foreach (int id in m_players.Keys)
        {
            Network.Server.Send(se, id, true);
        }
    }
コード例 #2
0
ファイル: GameLogic.cs プロジェクト: Retro11231/ESPN_Main
 void AddShotToList(short PlayerWhoShot, float TimeofShot)
 {
     ShotEvent CurrentShot = new ShotEvent();
     CurrentShot.PlayerWhoShot = PlayerWhoShot;
     CurrentShot.TimeTheyShot = TimeofShot;
     ShotEvents.Add(CurrentShot);
 }
コード例 #3
0
        public bool Execute(EventBase e)
        {
            ShotEvent ps = (ShotEvent)e;

            Network.Client.RespondToReliableEvent(ps.m_reliableEventId);
            Debug.Log("Received reliable event: " + ps.m_reliableEventId);

            if (WasExecuted(0, ps.m_reliableEventId))
            {
                return(false);
            }

            PlayerInstanceState pis = null;

            m_manager.playerInstances.TryGetValue(ps.m_who, out pis);
            if (pis != null)
            {
                m_manager.shotDatas.Enqueue(new ShotData()
                {
                    controller = pis.controller,
                    direction  = ps.m_direction,
                    point      = ps.m_point
                });
            }

            AddExecuted(0, ps.m_reliableEventId);
            return(true);
        }
コード例 #4
0
 private void UndoShot()
 {
     if (_shots.Count != 0)
     {
         ShotEvent shot = _shots.Pop().UndoShot();
         if (shot.WasHit)
         {
             Opponent.UndoHit(shot.CoordX, shot.CoordY, shot.ShipNumb);
         }
     }
     else
     {
         Console.WriteLine("You can't undo the game.");
     }
 }
コード例 #5
0
    private void Shoot(Vector2 direction)
    {
        ShotEvent se = new ShotEvent();

        se.m_direction       = direction;
        se.m_who             = Network.Client.ConnectionId;
        se.m_reliableEventId = Network.Client.GetNewReliableEventId();
        Network.Client.Send(se); Network.Client.Send(se);

        Debug.DrawRay(CharacterController.Player.transform.position, direction);
//#if DEBUG_SHIT
//        if (CharacterController.Player)
//            CharacterController.Player
//                .Shoot(direction);
//        #endif
    }
コード例 #6
0
        public bool Execute(EventBase e)
        {
            ShotEvent shot = (ShotEvent)e;

            Network.Server.RespondToReliableEvent(shot.m_reliableEventId, shot.m_who);

            if (!WasExecuted(shot.m_who, shot.m_reliableEventId))
            {
                PlayerPawn pawn = m_world.TryGetPawn(shot.m_who);
                //Console.WriteLine("Looking for pawn with id " + input.m_sessionId + ": " + pawn);
                if (pawn != null && pawn.m_isPlayingNow)
                {
                    pawn.ShootAtDirection(shot.m_direction);
                }

                AddExecuted(shot.m_who, shot.m_reliableEventId);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #7
0
        void LabelClick(object sender, EventArgs e)
        {
            Label correctLabel = (Label)sender;

            correctLabel.Hide();
            ShotEvent se = null;

            for (int i = 0; i < FileList.Count; i++)
            {
                if (FileList[i].textLabel == correctLabel)
                {
                    se = FileList[i];
                    FileList.Remove(se);
                    ShotEvent.ReduceAbovePoint(i);
                    break;
                }
            }

            if (pause.Text == "Play")
            {
                EnableBuildFile();
            }
        }
コード例 #8
0
    private void AddShotEventToDict()
    {
        if (ShotEventDictionary.Count != 0)
        {
            ShotEventDictionary.Clear();
        }

        if (scenarioContainer.EventSet.ShotEventList == null)
        {
            Debug.Log("XML파일 EventSet의 ShotEventList가 없다.");
            return;
        }

        for (int k = 0; k < scenarioContainer.EventSet.ShotEventList.Length; k++)
        {
            int       key           = scenarioContainer.EventSet.ShotEventList[k].ID;
            ShotEvent ShotEventInfo = scenarioContainer.EventSet.ShotEventList[k];

            if (!ShotEventDictionary.ContainsKey(key))
            {
                ShotEventDictionary.Add(key, ShotEventInfo);
            }
        }
    }
コード例 #9
0
 /**
  * raises ShotEvent
  */
 private void OnShotEvent()
 {
     _isShot = true;
     ShotEvent?.Invoke(this, EventArgs.Empty);
 }
コード例 #10
0
 public EventType GetEventType()
 {
     return((EventType)ShotEvent.GetStaticId());
 }
コード例 #11
0
 public void Shot()
 {
     ShotEvent?.Invoke();
 }