Example #1
0
 public void Serialize(NetDataWriter writer)
 {
     writer.Put(PlayerId);
     writer.Put(LocalPlanetId);
     Color.Serialize(writer);
     LocalPlanetPosition.Serialize(writer);
     UPosition.Serialize(writer);
     Rotation.Serialize(writer);
     BodyRotation.Serialize(writer);
     Mecha.Serialize(writer);
 }
 public override void OnEnter()
 {
     Initialize();
     base.OnEnter();
     characterBody.SetAimTimer(maximumDuration);
     Util.PlaySound(playAttackSoundString, gameObject);
     Util.PlaySound(playLoopSoundString, gameObject);
     aimRay      = GetAimRay();
     enemyFinder = new BullseyeSearch
     {
         maxDistanceFilter = maxDistance,
         maxAngleFilter    = lockOnAngle,
         searchOrigin      = aimRay.origin,
         searchDirection   = aimRay.direction,
         filterByLoS       = false,
         sortMode          = BullseyeSearch.SortMode.Angle,
         teamMaskFilter    = TeamMask.allButNeutral
     };
     if (teamComponent)
     {
         enemyFinder.teamMaskFilter.RemoveTeam(teamComponent.teamIndex);
     }
     muzzle      = transform.Find("ModelBase").Find("mdlBeamDrone").Find("AimOrigin");
     laserEffect = Object.Instantiate(laserPrefab, muzzle.position, muzzle.rotation);
     laserEffect.transform.parent = muzzle;
     laserChildLocator            = laserEffect.GetComponent <ChildLocator>();
     laserEffectEnd = laserChildLocator.FindChild("LaserEnd");
     UpdateLockOn();
     GradiusOption.instance.FireForAllOptions(characterBody, (option, behavior, _t, _d) =>
     {
         if (behavior.U.SafeCheck("laserFire"))
         {
             Destroy(behavior.U["laserFire"]);
         }
         if (behavior.U.SafeCheck("laserChildLocator"))
         {
             Destroy(behavior.U["laserChildLocator"]);
         }
         if (behavior.U.SafeCheck("laserFireEnd"))
         {
             Destroy(behavior.U["laserFireEnd"]);
         }
         Transform transform     = option.transform;
         behavior.U["laserFire"] = Object.Instantiate(laserPrefab, transform.position, transform.rotation);
         ((GameObject)behavior.U["laserFire"]).transform.parent = transform;
         behavior.U["laserChildLocator"] = ((GameObject)behavior.U["laserFire"]).GetComponent <ChildLocator>();
         behavior.U["laserFireEnd"]      = ((ChildLocator)behavior.U["laserChildLocator"]).FindChild("LaserEnd");
     });
     bodyRotation            = transform.GetComponentInChildren <BodyRotation>();
     bodyRotation.accelerate = true;
 }
Example #3
0
 public void Serialize(INetDataWriter writer)
 {
     writer.Put(Username);
     writer.Put(PlayerId);
     writer.Put(LocalPlanetId);
     writer.Put(MechaColors?.Length ?? 0);
     for (int i = 0; i < (MechaColors?.Length ?? 0); i++)
     {
         MechaColors[i].Serialize(writer);
     }
     LocalPlanetPosition.Serialize(writer);
     UPosition.Serialize(writer);
     Rotation.Serialize(writer);
     BodyRotation.Serialize(writer);
     Mecha.Serialize(writer);
     writer.Put(Appearance != null);
     if (Appearance != null)
     {
         using (MemoryStream ms = new MemoryStream())
         {
             using (BinaryWriter wr = new BinaryWriter(ms))
             {
                 Appearance.Export(wr);
             }
             byte[] export = ms.ToArray();
             writer.Put(export.Length);
             writer.Put(export);
         }
     }
     writer.Put(DIYAppearance != null);
     if (DIYAppearance != null)
     {
         using (MemoryStream ms = new MemoryStream())
         {
             using (BinaryWriter wr = new BinaryWriter(ms))
             {
                 DIYAppearance.Export(wr);
             }
             byte[] export = ms.ToArray();
             writer.Put(export.Length);
             writer.Put(export);
         }
     }
     writer.Put(DIYItemId.Length);
     for (int i = 0; i < DIYItemId.Length; i++)
     {
         writer.Put(DIYItemId[i]);
         writer.Put(DIYItemValue[i]);
     }
 }
        private void ModifyDroneModel(CharacterBody bodyRed, CharacterBody bodyGreen)
        {
            GameObject customModel = assetBundle.LoadAsset <GameObject>("Assets/Drones/PsiBits/Model/mdlPsiBitRed.prefab");

            droneBodyRed.ReplaceModel(customModel, DebugCheck());
            customModel.transform.localRotation = Util.QuaternionSafeLookRotation(Vector3.left);
            customModel.InitializeDroneModelComponents(bodyRed, 3f);
            customModel.transform.Find("Core").gameObject.AddComponent <CoreFlicker>();
            BodyRotation rotationComponent = customModel.transform.parent.gameObject.AddComponent <BodyRotation>();

            rotationComponent.rotationDirection = -1;
            rotationComponent.rotationSpeed     = 6f;
            customModel = assetBundle.LoadAsset <GameObject>("Assets/Drones/PsiBits/Model/mdlPsiBitGreen.prefab");
            droneBodyGreen.ReplaceModel(customModel, DebugCheck());
            customModel.transform.localRotation = Util.QuaternionSafeLookRotation(Vector3.left);
            customModel.InitializeDroneModelComponents(bodyGreen, 3f);
            customModel.transform.Find("Core").gameObject.AddComponent <CoreFlicker>();
            rotationComponent = customModel.transform.parent.gameObject.AddComponent <BodyRotation>();
            rotationComponent.rotationDirection = 1;
            rotationComponent.rotationSpeed     = 6f;
        }
Example #5
0
 public override void OnEnter()
 {
     Initialize();
     base.OnEnter();
     duration = baseDuration / attackSpeedStat;
     if (characterBody)
     {
         characterBody.SetAimTimer(duration);
         if (isAuthority)
         {
             AkSoundEngine.PostEvent(ChargeLaserEventId, gameObject);
         }
     }
     muzzle       = transform.Find("ModelBase").Find("mdlLaserDrone").Find("AimOrigin").gameObject;
     chargeEffect = muzzle.GetComponent <ChargeEffect>();
     chargeEffect.startCharging = true;
     if (particleEffectPrefab)
     {
         particleChargeEffect = Object.Instantiate(particleEffectPrefab, muzzle.transform.position, muzzle.transform.rotation);
         particleChargeEffect.transform.parent = transform;
         var particleSystem = particleChargeEffect.GetComponent <ScaleParticleSystemDuration>();
         if (particleSystem)
         {
             particleSystem.newDuration = duration;
         }
         GradiusOption.instance.FireForAllOptions(characterBody, (option, behavior, _t, _d) =>
         {
             behavior.U["laserChargeEffect"] = Object.Instantiate(particleEffectPrefab, option.transform.position, option.transform.rotation);
             ((GameObject)behavior.U["laserChargeEffect"]).transform.parent = option.transform;
             var optionParticleSystem = ((GameObject)behavior.U["laserChargeEffect"]).GetComponent <ScaleParticleSystemDuration>();
             if (optionParticleSystem)
             {
                 optionParticleSystem.newDuration = duration;
             }
         });
     }
     bodyRotation            = transform.GetComponentInChildren <BodyRotation>();
     bodyRotation.accelerate = true;
 }
Example #6
0
        public Skeleton ToNetworkModel()
        {
            Skeleton s = new Skeleton();

            s.UserId        = UserId;
            s.BodyLocation  = BodyLocation.ToCoord();
            s.BodyRotation  = BodyRotation.ToCoord();
            s.Head          = Head.ToCoord();
            s.Neck          = Neck.ToCoord();
            s.Spine         = Spine.ToCoord();
            s.Hips          = Hips.ToCoord();
            s.LeftShoulder  = LeftShoulder.ToCoord();
            s.LeftArm       = LeftArm.ToCoord();
            s.LeftHand      = LeftHand.ToCoord();
            s.RightShoulder = RightShoulder.ToCoord();
            s.RightArm      = RightArm.ToCoord();
            s.RightHand     = RightHand.ToCoord();
            s.LeftKnee      = LeftKnee.ToCoord();
            s.LeftFoot      = LeftFoot.ToCoord();
            s.RightKnee     = RightKnee.ToCoord();
            s.RightFoot     = RightFoot.ToCoord();
            return(s);
        }
Example #7
0
 void Awake()
 {
     _bodyRotation = GetComponent <BodyRotation>();
 }
Example #8
0
 public void MergeFrom(Skeleton other)
 {
     if (other == null)
     {
         return;
     }
     if (other.UserId != 0UL)
     {
         UserId = other.UserId;
     }
     if (other.bodyLocation_ != null)
     {
         if (bodyLocation_ == null)
         {
             bodyLocation_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         BodyLocation.MergeFrom(other.BodyLocation);
     }
     if (other.bodyRotation_ != null)
     {
         if (bodyRotation_ == null)
         {
             bodyRotation_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         BodyRotation.MergeFrom(other.BodyRotation);
     }
     if (other.head_ != null)
     {
         if (head_ == null)
         {
             head_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         Head.MergeFrom(other.Head);
     }
     if (other.neck_ != null)
     {
         if (neck_ == null)
         {
             neck_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         Neck.MergeFrom(other.Neck);
     }
     if (other.spine_ != null)
     {
         if (spine_ == null)
         {
             spine_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         Spine.MergeFrom(other.Spine);
     }
     if (other.hips_ != null)
     {
         if (hips_ == null)
         {
             hips_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         Hips.MergeFrom(other.Hips);
     }
     if (other.leftShoulder_ != null)
     {
         if (leftShoulder_ == null)
         {
             leftShoulder_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         LeftShoulder.MergeFrom(other.LeftShoulder);
     }
     if (other.leftArm_ != null)
     {
         if (leftArm_ == null)
         {
             leftArm_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         LeftArm.MergeFrom(other.LeftArm);
     }
     if (other.leftHand_ != null)
     {
         if (leftHand_ == null)
         {
             leftHand_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         LeftHand.MergeFrom(other.LeftHand);
     }
     if (other.rightShoulder_ != null)
     {
         if (rightShoulder_ == null)
         {
             rightShoulder_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         RightShoulder.MergeFrom(other.RightShoulder);
     }
     if (other.rightArm_ != null)
     {
         if (rightArm_ == null)
         {
             rightArm_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         RightArm.MergeFrom(other.RightArm);
     }
     if (other.rightHand_ != null)
     {
         if (rightHand_ == null)
         {
             rightHand_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         RightHand.MergeFrom(other.RightHand);
     }
     if (other.leftKnee_ != null)
     {
         if (leftKnee_ == null)
         {
             leftKnee_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         LeftKnee.MergeFrom(other.LeftKnee);
     }
     if (other.leftFoot_ != null)
     {
         if (leftFoot_ == null)
         {
             leftFoot_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         LeftFoot.MergeFrom(other.LeftFoot);
     }
     if (other.rightKnee_ != null)
     {
         if (rightKnee_ == null)
         {
             rightKnee_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         RightKnee.MergeFrom(other.RightKnee);
     }
     if (other.rightFoot_ != null)
     {
         if (rightFoot_ == null)
         {
             rightFoot_ = new global::VrLifeShared.Networking.NetworkingModels.Coord();
         }
         RightFoot.MergeFrom(other.RightFoot);
     }
 }
Example #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (UserId != 0UL)
            {
                hash ^= UserId.GetHashCode();
            }
            if (bodyLocation_ != null)
            {
                hash ^= BodyLocation.GetHashCode();
            }
            if (bodyRotation_ != null)
            {
                hash ^= BodyRotation.GetHashCode();
            }
            if (head_ != null)
            {
                hash ^= Head.GetHashCode();
            }
            if (neck_ != null)
            {
                hash ^= Neck.GetHashCode();
            }
            if (spine_ != null)
            {
                hash ^= Spine.GetHashCode();
            }
            if (hips_ != null)
            {
                hash ^= Hips.GetHashCode();
            }
            if (leftShoulder_ != null)
            {
                hash ^= LeftShoulder.GetHashCode();
            }
            if (leftArm_ != null)
            {
                hash ^= LeftArm.GetHashCode();
            }
            if (leftHand_ != null)
            {
                hash ^= LeftHand.GetHashCode();
            }
            if (rightShoulder_ != null)
            {
                hash ^= RightShoulder.GetHashCode();
            }
            if (rightArm_ != null)
            {
                hash ^= RightArm.GetHashCode();
            }
            if (rightHand_ != null)
            {
                hash ^= RightHand.GetHashCode();
            }
            if (leftKnee_ != null)
            {
                hash ^= LeftKnee.GetHashCode();
            }
            if (leftFoot_ != null)
            {
                hash ^= LeftFoot.GetHashCode();
            }
            if (rightKnee_ != null)
            {
                hash ^= RightKnee.GetHashCode();
            }
            if (rightFoot_ != null)
            {
                hash ^= RightFoot.GetHashCode();
            }
            return(hash);
        }
Example #10
0
 void Start()
 {
     _bodyRotation  = GetComponent <BodyRotation>();
     _targeting     = GetComponent <Targeting>();
     _mousePosition = GameObject.FindGameObjectWithTag(Tags.CURSOR).GetComponent <Transform>();
 }