public void CreateAndFire(Vector2 from, Vector2 to, float time) { var meteor = _meteorPool.Pop(); var projector = _projPool.Pop(); ForDisassemble.Add(meteor.GetHashCode(), meteor); //костылище // ForDisassemble.Add(projector.GetHashCode(),projector); // _style.StylizeMeteor(meteor, projector); var pos = new Vector3(to.x, HitVelocity * time, to.y); meteor.transform.position = pos; meteor.GetComponent <Meteor>().Projector = projector; meteor.GetComponent <Rigidbody>().velocity = new Vector3(0, -HitVelocity, 0); pos.x = from.x; pos.z = from.y; pos.y = ProjectorStartY; projector.transform.position = pos; var distance = new Vector3(to.x - from.x, 0, to.y - from.y); var velocity = distance / time; projector.GetComponent <Rigidbody>().velocity = velocity; projector.GetComponent <ConstantForce>().force = new Vector2(0, -(ProjectorStartY - ProjectorEndY) * 2 / (time * time)); }
public GameObject Build(IDescriptorWithID desc) { GameObject puddle = null; if (!(desc is OilPuddleDescriptor || desc is OilEndDescriptor)) { throw new ArgumentException(); } if (desc is OilPuddleDescriptor) { var d = (OilPuddleDescriptor)desc; switch (d.State) { case OilPuddleDescriptor.PosState.First: puddle = _firstPool.Pop(); _style.StylizeFirstPuddle(puddle); break; case OilPuddleDescriptor.PosState.Last: puddle = _transitPool.Pop(); _style.StylizeLastPuddle(puddle); break; case OilPuddleDescriptor.PosState.Transitional: puddle = _transitPool.Pop(); _style.StylizeTransitPuddle(puddle); break; default: throw new ArgumentOutOfRangeException(); } puddle.transform.position = d.Position.MyVec2ToVec3(DefaultPosY); var scale = new Vector3(d.Width, d.Length, 1); puddle.transform.localScale = scale; } else { var end = _endPool.Pop(); end.transform.position = ((OilEndDescriptor)desc).Position.MyVec2ToVec3(_endPosY); ForDisassemble.Add(end.GetHashCode(), end); } return(puddle); }
private void Fire() { var go = ProjectilePool.Pop(); go.transform.rotation = transform.rotation; //todo go.transform.position = transform.position + transform.rotation * new Vector3(0, 0.2f, .32f); //Vector3(0,.82f,.6f); var resVelocity = _dir * _shellVelocity; resVelocity.z += _avatar.Vehicle.Velocity.z; go.GetComponent <Rigidbody>().velocity = resVelocity; }
//todo red0 private void Fire() { var angle = Vector3.SignedAngle( Vector3.forward, AvatarTransform.position - transform.position, Vector3.up); Debug.Log(angle + " angle"); var pos = transform.position; pos.y = .717f; var missile = MissilePool.Pop(); missile.GetComponent <HomingMissile>().Init(_missileVelocity, _missileRotVelocity, _missileLimit); }
public GameObject Build(IDescriptorWithID desc) { if (!(desc is WallDescriptor)) { throw new ArgumentException(); } var wall = _wallPool.Pop(); _style.StylizeWall(wall); var d = (WallDescriptor)desc; wall.transform.position = d.Position.MyVec2ToVec3(); var scale = wall.transform.localScale; scale.z = d.Length; wall.transform.localScale = scale; return(wall); }
public GameObject Build(IDescriptorWithID desc) { if (!(desc is CopterDescriptor || desc is CopterRecallDescriptor)) { throw new ArgumentException(); } if (desc is CopterRecallDescriptor) { _copterQueue.Dequeue().GetComponent <Copter>().Recall(this); } else { var go = _copterPool.Pop(); _style.StylizeCopter(go); var copter = go.GetComponent <Copter>(); var d = (CopterDescriptor)desc; copter.Init(d.ReloadTime, d.MissileVelocity, d.MissileRotationVelocity, d.MissileLimit, d.MiddlePosX); copter.TakePosition(); _copterQueue.Enqueue(go); return(go); } return(null); }
public GameObject Build(IDescriptorWithID desc) { if (!(desc is VehicleDescriptor)) { throw new ArgumentException(); } GameObject go = null; Vehicle.VehicleBehaviour behaviour = null; Vehicle vehicle; var bt = Vehicle.BlockType.S1; var size = 0; if (desc is MilitaryDescriptor) { go = _mPool.Pop(); _style.StylizeMilitary(go); behaviour = new Vehicle.MilitaryCar((MilitaryDescriptor)desc); } else if (desc is PoliceDescriptor) { go = _pPool.Pop(); _style.StylizePolice(go); behaviour = new Vehicle.PoliceCar((PoliceDescriptor)desc); } else if (desc is CarDescriptor) { switch (((CarDescriptor)desc).Size) { case 1: go = _s1Pool.Pop(); _style.StylizeCar1(go); break; case 2: go = _s2Pool.Pop(); _style.StylizeCar2(go); bt = Vehicle.BlockType.S2; size = 2; break; case 3: go = _s3Pool.Pop(); _style.StylizeCar3(go); bt = Vehicle.BlockType.S3; size = 3; break; } if (desc is WobblingCarDescriptor) { behaviour = new Vehicle.WobblingCar((WobblingCarDescriptor)desc); } else if (desc is SlidingCarDescriptor) { behaviour = new Vehicle.SlidingCar((SlidingCarDescriptor)desc); } else if (desc is AutoMeteorCarDescriptor) { behaviour = new Vehicle.AutoMeteorCar((AutoMeteorCarDescriptor)desc); } else { behaviour = new Vehicle.SimpleCar((CarDescriptor)desc); } } else if (desc is TrailerDescriptor) { go = _tPool.Pop(); _style.StylizeTrailer(go); behaviour = new Vehicle.Trailer((TrailerDescriptor)desc); } go.transform.position = ((VehicleDescriptor)desc).Position.MyVec2ToVec3(); go.transform.rotation = Quaternion.identity; vehicle = go.GetComponent <Vehicle>(); vehicle.Rezet(); if (size == 0) { vehicle.InitSize(); } else { vehicle.InitSize(bt, size); } vehicle.InitBehaviour(behaviour); return(go); }