Ejemplo n.º 1
0
        public static Google.Protobuf.WellKnownTypes.Any InteractionToAny(EventInteractionTick iTick)
        {
            WarPb.DecimalVector3 v = new WarPb.DecimalVector3();
            v.X = iTick.DV.x.ToString();
            v.Y = iTick.DV.y.ToString();
            v.Z = iTick.DV.z.ToString();

            Google.Protobuf.IMessage action;
            switch (iTick.T)
            {
            case EventInteractionTick.TYPE.MOVE:
                WarPb.Move move = new WarPb.Move();
                move.Uid   = 2002;
                move.Speed = v;
                action     = move;
                break;

            case EventInteractionTick.TYPE.SHOOT:
                WarPb.Shoot shoot = new WarPb.Shoot();
                shoot.Uid   = 2002;
                shoot.Super = false;
                shoot.Point = v;
                action      = shoot;
                break;

            default:
                return(null);
            }

            var any = Google.Protobuf.WellKnownTypes.Any.Pack(action);

            return(any);
        }
Ejemplo n.º 2
0
 public void Do(float dt)
 {
     if (!moveForward.Equals(Vector3.zero))
     {
         m_Movement.DoMove(dt, moveForward);
     }
     if (FireInfo != null)
     {
         m_Shooting.DoFire(FireInfo);
         FireInfo = null;
     }
 }
Ejemplo n.º 3
0
        public AudioClip m_FireClip;         // Audio that plays when each shot is fired.
        //public float m_MinLaunchForce = 15f;        // The force given to the shell if the fire button is not held.
        //public float m_MaxLaunchForce = 30f;        // The force given to the shell if the fire button is held for the max charge time.
        //public float m_MaxChargeTime = 0.75f;       // How long the shell can charge for before it is fired at max force.


        //point 为点击的位置
        public void DoFire(WarPb.Shoot fire)
        {
            Vector3    point    = new Vector3(float.Parse(fire.Point.X), m_FireTransform.position.y, float.Parse(fire.Point.Z));
            Vector3    forward  = point - m_FireTransform.position;
            Quaternion rotation = Quaternion.FromToRotation(m_FireTransform.forward, forward);

            Rigidbody shellInstance = Instantiate(m_Shell, m_FireTransform.position, m_FireTransform.rotation * rotation) as Rigidbody;

            shellInstance.velocity = 40 * forward.normalized;

            m_ShootingAudio.clip = m_FireClip;
            m_ShootingAudio.Play();
        }
Ejemplo n.º 4
0
        }                                               //NOTE: 射击信息
        //public Vector3 FirePoint { set; get; }      //NOTE: 射击位置,下一次Do 的时候处理

        public void Setup()
        {
            m_Movement         = m_Instance.GetComponent <Views.TankMovement>();
            m_Shooting         = m_Instance.GetComponent <Views.TankShooting>();
            m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

            m_Movement.m_Uid = m_Uid;
            m_Shooting.m_Uid = m_Uid;

            moveForward = Vector3.zero;
            FireInfo    = null;


            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_Uid + "</color>";

            MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer>();

            for (int i = 0; i < renderers.Length; i++)
            {
                renderers[i].material.color = m_PlayerColor;
            }
        }