撃ちだした弾の管理を行うクラス
Inheritance: MonoBehaviour
コード例 #1
0
ファイル: Enemy.cs プロジェクト: ktn/KevinEnemyPractice
    public void Update()
    {
        this.x -= speedX;
        this.y += speedY;

        if(frameCount%shotrate == 0)
        {
            _shot = new Shot(this);
            _shot.x = this.x;
            _shot.y = this.y;
            _shots.Add(_shot);
            Futile.stage.AddChild(_shot);
        }

        for(int b = _shots.Count - 1; b>=0; b--)
        {
            _shots[b].Update ();
            Shot shotted = _shots[b];
            if(shotted.x < -Futile.screen.halfWidth)
            {
                shotted.RemoveFromContainer();
                _shots.Remove(shotted);
                Debug.Log ("NO BAD BANANA");
            }
        }

        frameCount += 1;
        //Debug.Log (speedX);
    }
コード例 #2
0
    void Awake()
    {
        cameraScript = GetComponent<MouseLook>();
        cameraScript2 = camera.GetComponent<MouseLook>();
        controllerScript = GetComponent<CharacterMotor>();
        shotScript = GetComponent<Shot>();

         if (photonView.isMine)
        {
            this.camera.camera.enabled=true;
            cameraScript.enabled = true;
            cameraScript2.enabled = true;
            controllerScript.canControl = true;
            shotScript.enabled=true;
        }
        else
        {
            this.camera.camera.enabled=false;
            cameraScript.enabled = false;
            cameraScript2.enabled = false;
            controllerScript.canControl = false;
            shotScript.enabled=false;
        }

        gameObject.name = gameObject.name + photonView.viewID.ID;
    }
コード例 #3
0
		public void Fire(Vector3Df position, Vector3Df direction, uint time)
		{
			Shot s = new Shot();
			s.direction = direction;

			Vector3Df e = position + s.direction * worldInfinity;
			Line3Df l = new Line3Df(position, e);

			Vector3Df cv;
			Triangle3Df ct;
			SceneNode cn;
			if (sceneManager.SceneCollisionManager.GetCollisionPoint(l, worldTriangles, out cv, out ct, out cn))
				e = cv;

			s.deathTime = time + (uint)((e - position).Length / shotSpeed);

			s.node = sceneManager.AddSphereSceneNode(10);
			s.node.SetMaterialFlag(MaterialFlag.Lighting, false);
			sceneManager.MeshManipulator.SetVertexColors(((MeshSceneNode)s.node).Mesh, Color.OpaqueWhite);

			s.node.AddAnimator(sceneManager.CreateFlyStraightAnimator(position, e, (s.deathTime - time) / 1000.0f));
			s.node.AnimatorList[0].Drop();

			sceneManager.AddLightSceneNode(s.node);

			shots.Add(s);
		}
コード例 #4
0
ファイル: AnnotationForm.cs プロジェクト: Silox/UGent-stuff
        public AnnotationForm(ShotDetectionModel shotDetectionModel, Shot shot)
        {
            InitializeComponent();

            this.shotDetectionModel = shotDetectionModel;
            this.shot = shot;
            txtAnnotations.Text = String.Join(", ", shot.Annotations);
        }
コード例 #5
0
ファイル: Gamepage.cs プロジェクト: ktn/KevinEnemyPractice
 public void HandleShoot(FButton button)
 {
     _shot = new Shot();
     _shot.x = _holder.x + 10;
     _shot.y = _holder.y;
     Futile.stage.AddChild(_shot);
     _shots.Add(_shot);
 }
コード例 #6
0
ファイル: ShotFixture.cs プロジェクト: Felixdev/dogfight2008
 public void Accessors()
 {
     Shot shot = new Shot(new Vector2(0, 1), 2, 3, 0);
       Assert.AreEqual(0, shot.Position.X);
       Assert.AreEqual(1, shot.Position.Y);
       Assert.AreEqual(2, shot.Angle);
       Assert.AreEqual(3, shot.Speed);
 }
コード例 #7
0
ファイル: Bot.cs プロジェクト: aiclub/Mohawk_Battleship
        public void fire()
        {
            resultThisTurn = false; // will be used to store result of this shot, is set to true within shotHit
            Coordinates coords = pickTarget();

            huntingMap.setValue(coords, 0);

            shotThisTurn = this.player.Shoot(coords.X, coords.Y);
        }
コード例 #8
0
ファイル: ShotFixture.cs プロジェクト: Felixdev/dogfight2008
 public void Tick()
 {
     double angle = Calc.DegreesToRadians(45);
       Shot shot = new Shot(new Vector2(0, 1), angle, 1, 0);
       shot.Tick(1);
       Vector2 exp = Calc.v(Math.Cos(angle), 1+Math.Sin(angle));
       Assert.AreEqual(exp.X, shot.Position.X);
       Assert.AreEqual(exp.Y, shot.Position.Y);
 }
コード例 #9
0
    protected override float update(Transform currentCamera, Actor[] subjects, Shot shot, float maxExecutionTime)
    {
        double maxMilliseconds = maxExecutionTime * 1000;
        double begin = System.DateTime.Now.TimeOfDay.TotalMilliseconds;

        //Wiced Improvement
        setPosition(bestPosition + SubjectsVelocity*Time.deltaTime,currentCamera,shot);

        bestFitness = shot.GetQuality (subjects,currentCamera.GetComponent<Camera> ());
        float lookAtFitness = shot.InFrustum(subjects) * .5f + shot.GetQuality (lookAtInfluencingProperties,subjects) * .5f;
        bestPosition = currentCamera.transform.position;

        while (System.DateTime.Now.TimeOfDay.TotalMilliseconds - begin < maxMilliseconds) {

            Vector3 positionForce = Vector3.zero;
            foreach (Property p in shot.Properties) {
                if (p is ProjectionSize)
                    positionForce += ((ProjectionSize)p).PositionForce (subjects, currentCamera);
                if (p is VantageAngle)
                    positionForce += ((VantageAngle)p).PositionForce (subjects, currentCamera);
            }

            foreach (Actor s in subjects)
                positionForce += PropertiesForces.OcclusionAvoidanceForce(s,currentCamera);

            foreach (Actor s in subjects)
                positionForce += PropertiesForces.InFrustumForce(s,currentCamera);

            if (positionForce.magnitude >1)
                positionForce.Normalize();

            //Wiced Improvement
            setPosition(bestPosition + positionForce + Random.insideUnitSphere * (1 - Mathf.Pow (bestFitness, 2)) * CombinedSubjectsScale(subjects),currentCamera,shot);
            //Previous: setPosition(bestPosition + positionForce,currentCamera,shot);

            //Wiced Improvement
            Vector3 tmpLookAt = SubjectsCenter (subjects) + Random.insideUnitSphere * (1 - Mathf.Pow (lookAtFitness, 4)) * CombinedSubjectsScale(subjects);
            //Previous: Vector3 tmpLookAt = SubjectsCenter (subjects) + Random.insideUnitSphere * (1-lookAtFitness);

            currentCamera.LookAt (tmpLookAt);
            float tmpFit = shot.GetQuality (subjects,currentCamera.GetComponent<Camera> ());

            logTrace (currentCamera.position, currentCamera.forward, tmpFit);

            if (tmpFit > bestFitness) {
                bestFitness = tmpFit;
                bestPosition = currentCamera.position;
                bestForward = currentCamera.forward;
            }
        }

        currentCamera.position = bestPosition;
        currentCamera.forward = bestForward;

        return bestFitness;
    }
コード例 #10
0
ファイル: ShotFixture.cs プロジェクト: Felixdev/dogfight2008
 public void GetBox2d()
 {
     double speed = 1; // 1 m / ms
       double deltaMS = 10;
       double explength = speed * deltaMS;
       Box2d expected = new Box2d(10 + explength, 20, 0, explength, -0.01, 0.01, 0);
       Shot shot = new Shot(Calc.v(10, 20), 0, speed, 0);
       shot.Tick(deltaMS);
       Box2d result = shot.GetBox2d();
       Assert.AreEqual(expected, result);
 }
コード例 #11
0
ファイル: Solver.cs プロジェクト: paoloburelli/camon
    /// <summary>
    /// Sets the position to the camera controlling if the camera is locked
    /// </summary>
    /// <param name="position">The position to be set.</param>
    /// <param name="bestCamera">The camera on which to set the position.</param>
    /// <param name="shot">The current shot.</param>
    public static void setPosition(Vector3 position, Transform bestCamera, Shot shot)
    {
        if (shot.LockX || float.IsNaN(position.x))
            position.x = bestCamera.position.x;
        if (shot.LockY || float.IsNaN(position.y))
            position.y = bestCamera.position.y;
        if (shot.LockZ || float.IsNaN(position.z))
            position.z = bestCamera.position.z;

        bestCamera.position = position;
    }
コード例 #12
0
ファイル: Player.cs プロジェクト: JeffHemming/Battleship
 //Take a square from Form, evaluate if square is legal, create shot object, send/receive over network.
 public bool shoot(Square shotSquare)
 {
     if(shotSquare.State.empty)
     {
         Shot newShot = new Shot(shotSquare);
         //sendShot(newShot);
         //receiveShot(incomingPacket);
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #13
0
    //trajectory mapping
    public void PlotTrajectory(Vector3 start, Vector3 velocity, Shot.ShotParams shotParams)
    {
        if (Vector3.Distance (velocity, lastVelocity) > redrawThreshhold) {
            lastVelocity = velocity;

            trajectory.SetPosition(0, start);
            trajectory.SetPosition(1, start + (velocity * directionIndecatorLengthMultiplier));

            if(velocity.y > 0) {
                trajectory.SetColors (shotParams.GetColor(), shotParams.GetColor());
            } else {
                hideTrajectory();
            }
        }
    }
コード例 #14
0
    //Wiced Improvement
    protected override void initBestCamera(Transform bestCamera, Actor[] subjects, Shot shot)
    {
        Vector3 rayCastPoint = subjects[0].Position;

        float radius = Solver.SubjectsRadius (subjects);
        Vector3 direction = Vector3.one * radius;
        Vector3 lookAtPoint = Solver.SubjectsCenter (subjects);

        foreach (Property p in shot.Properties) {
            if (p.PropertyType == Property.Type.VantageAngle) {
                VantageAngle va = (VantageAngle)p;
                subjects[va.MainSubjectIndex].CalculateRelativeCameraAngle(va.DesiredHorizontalAngle,va.DesiredVerticalAngle);
                direction = subjects[p.MainSubjectIndex].VantageDirection * radius;
                lookAtPoint = subjects [va.MainSubjectIndex].Position;
                rayCastPoint = subjects [va.MainSubjectIndex].Position;
                break;
            } else if (p.PropertyType == Property.Type.RelativePosition) {
                RelativePosition rp = (RelativePosition)p;
                if (rp.DesiredPosition == RelativePosition.Position.InFrontOf) {
                    direction = ((subjects [rp.MainSubjectIndex].Position - subjects [rp.SecondaryActorIndex].Position) + subjects [rp.MainSubjectIndex].Right * subjects [rp.MainSubjectIndex].VolumeOfInterestSize.x);
                    direction *= 1.1f + (subjects [rp.MainSubjectIndex].VolumeOfInterestSize.magnitude / direction.magnitude);
                    lookAtPoint = subjects [rp.SecondaryActorIndex].Position;
                    rayCastPoint = subjects [rp.MainSubjectIndex].Position;
                    break;
                }
            }
        }

        //I'm not sure if the initial camera position should be calculated or it should be manually set
        setPosition(lookAtPoint + direction,bestCamera,shot);
        //bestCamera.position = lookAtPoint + direction;
        bestCamera.LookAt (lookAtPoint);

        float rayDistance = (bestCamera.position-rayCastPoint).magnitude;
        Vector3 rayDirection = (bestCamera.position-rayCastPoint).normalized;

        RaycastHit hitInfo;
        Physics.Raycast (rayCastPoint,rayDirection, out hitInfo,rayDistance);

        bool obstacle = hitInfo.distance < rayDistance;
        foreach (Actor a in subjects)
            if (a != null && hitInfo.collider == a.GetComponent<Collider>())
                obstacle = false;

        if (obstacle)
            Solver.setPosition(bestCamera.position - rayDirection * (rayDistance-hitInfo.distance),bestCamera,shot);
    }
コード例 #15
0
ファイル: Shot.cs プロジェクト: ITIGameDesign/QuickSnap
	static public Shot ParseShotXML(PT_XMLHashtable xHT)
	{
		Shot sh = new Shot ();

		sh.position.x = float.Parse(xHT.att("x"));
		sh.position.y = float.Parse(xHT.att("y"));
		sh.position.z = float.Parse(xHT.att("z"));
		sh.rotation.x = float.Parse(xHT.att("qx"));
		sh.rotation.y = float.Parse(xHT.att("qy"));
		sh.rotation.z = float.Parse(xHT.att("qz"));
		sh.rotation.w = float.Parse(xHT.att("qw"));
		sh.target.x = float.Parse(xHT.att("tx"));
		sh.target.y = float.Parse(xHT.att("ty"));
		sh.target.z = float.Parse(xHT.att("tz"));

		return (sh);
	}
コード例 #16
0
ファイル: BirdAgent.cs プロジェクト: Elinion/AngryBirds-PCG
	public void ThrowBird(Bird currentBird, Pig targetPig, Vector2 slingPos)
	{
		if(_lastTargetPig)
			_lastTargetPig.GetComponent<SpriteRenderer>().material.color = Color.white;

		IsThrowingBird = true;
		
		_throwTimer = 0f;
		_currentBird = currentBird;

		// Highlight the target
		if(!GameWorld.Instance._isSimulation)
			targetPig.GetComponent<SpriteRenderer>().material.color = Color.red;

		_nextShot = Solve(currentBird, targetPig, slingPos);
		currentBird.SelectBird();
	}
コード例 #17
0
ファイル: Player.cs プロジェクト: ninoaguilar/Battleship
 //Take a square from Form, evaluate if square is legal, create shot object, send/receive over network.
 public bool shoot(Square shotSquare)
 {
     // if(shotSquare.State.empty)
     // ^^ Getting an error
     // This might work better - Nino
     if(shotSquare.getSquareState() != State.hit && shotSquare.getSquareState() != State.miss)
     {
         Shot newShot = new Shot(shotSquare);
         //sendShot(newShot);
         //receiveShot(incomingPacket);
         return true;
     }
     else
     {
         return false;
     }
 }
コード例 #18
0
ファイル: Shot.cs プロジェクト: caardappel/shmupception
    public static Shot Create(Shot source, Gun gun)
    {
        GameObject go = null;

        GameObject effect = gun.effect;
        if (effect == null)
            effect = source.effectOverride;

        if (effect != null)
            go = (GameObject)Instantiate(effect);
        else
            go = new GameObject("Shot Delayer");

        Shot shot = go.AddComponent<Shot>();
        shot.Clone(source);

        return shot;
    }
コード例 #19
0
    void CreateShot()
    {
        if(alcoholSelected == 0)
        {
            //BEER
            shot = new Shot();
            shot.Amount.Add(300);
            shot.Amount.Add(500);
            shot.Amount.Add(1000);

            shot.Power = 5;
        }
        else if(alcoholSelected == 1 || alcoholSelected == 2)
        {
            //wine or champagne
            shot = new Shot();
            shot.Amount.Add(300/2);
            shot.Amount.Add(500/2);
            shot.Amount.Add(1000/2);

            shot.Power = 12;
        }else
        {
            //vodka spirit denaturate
            shot = new Shot();
            shot.Amount.Add(300 / 10);
            shot.Amount.Add(500 / 10);
            shot.Amount.Add(1000 / 10);

            if(alcoholSelected == 3)
            {
                shot.Power = 40;
            }
            else if(alcoholSelected == 4)
            {
                shot.Power = 95;
            }
            else
            {
                shot.Power = 92;
            }
        }
    }
コード例 #20
0
    void Awake()
    {
        cameraScript2 = this.GetComponent<MouseLook>();
        shotScript = this.GetComponent<Shot>();

         if (photonView.isMine)
        {
            //MINE: local player, simply enable the local scripts
            cameraScript2.enabled = true;
            shotScript.enabled = true;
        }
        else
        {
            cameraScript2.enabled = false;
            shotScript.enabled = false;
        }

        gameObject.name = gameObject.name + photonView.viewID.ID;
    }
コード例 #21
0
ファイル: Window.cs プロジェクト: Ico0/TelerikAcademy
 public static void PrintShotInConsoleInnerPart(Shot shot)
 {
     Console.SetCursorPosition(0, StartScreen.consoleWindowHeight - 1);
     Console.MoveBufferArea(shot.StartX - 2, shot.StartY, shot.Width, shot.Height,
                            shot.StartX - 1, shot.StartY);
 }
コード例 #22
0
 public StatResult <Shot> AddShot(TeamGame game, Shot shot)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
 public BonusPower(Shot main, Shot second, Shot focus)
 {
     _mainShotBullet      = main;
     _secondaryShotBullet = second;
     _focusShotBullet     = focus;
 }
コード例 #24
0
        public void Create(int gameId, int playerId, int holeId, int attempts, bool shotMade)
        {
            var game   = _gameRepository.GetById(gameId);
            var shots  = _shotRepository.GetByGame(gameId);
            var player = _playerRepository.GetById(playerId);
            var hole   = _holeRepository.GetById(holeId);

            var allHoles     = _holeRepository.All();
            var allShotTypes = _shotTypeRepository.All();

            int playerCurrentPoints = shots.Where(s => s.Player.Id == player.Id).Sum(s => s.Points);
            int totalPoints         = allHoles.Where(h => h.Id <= hole.Id).Sum(h => h.Par);
            int totalPointsTaken    = shots.Sum(s => s.Points);
            int pointsAvailable     = totalPoints - totalPointsTaken;

            var currentShot = new Shot
            {
                Game     = game,
                Player   = player,
                Hole     = hole,
                Attempts = attempts,
                ShotMade = shotMade
            };

            // If first shot of the game, logic is easy
            if (!shots.Any())
            {
                if (currentShot.ShotMade)
                {
                    currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypeMake);
                    currentShot.Points   = hole.Par;
                }
                else
                {
                    currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypeMiss);
                }
            }
            else
            {
                // If not the first shot, stuff starts getting a little complicated

                // If the shot was made, start the logic, else just put in a missed shot
                if (currentShot.ShotMade)
                {
                    // First lets check if it is the first shot of the current hole
                    if (shots.Any(s => s.Hole.Id == currentShot.Hole.Id && s.ShotMade == true))
                    {
                        // If it's not the first shot, figure out if it is a push
                        var currentLowestShotMade = shots.Where(s => s.Hole.Id == currentShot.Hole.Id && s.ShotMade == true).OrderBy(s => s.Attempts).First();

                        if (currentLowestShotMade.Attempts == currentShot.Attempts)
                        {
                            // This is a push
                            currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypePush);
                            currentShot.Points   = pointsAvailable;

                            // Zero out other player's points that this player pushed.
                            Update(currentLowestShotMade.Id, 0, allShotTypes.Single(st => st.Id == ShotTypeMake));
                        }
                        else
                        {
                            // Then it is a steal (because someone has already made it if we got to this point)

                            // TODO: Need to account for StainlessSteals here

                            // First figure out if the hole had been pushed, because then it will be a "Sugar-Free Steal"
                            if (shots.Any(s => s.Hole.Id == currentShot.Hole.Id && s.ShotType.Id == ShotTypePush))
                            {
                                // This is a sugar-free steal
                                currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypeSugarFreeSteal);
                                currentShot.Points   = pointsAvailable;

                                // Reset the person who had a push to just be a "Make" now
                                var playerWithPush = shots.Single(s => s.Hole.Id == currentShot.Hole.Id && s.ShotType.Id == ShotTypePush);
                                Update(playerWithPush.Id, 0, allShotTypes.Single(st => st.Id == ShotTypeMake));
                            }
                            else
                            {
                                var playerWithPoints = shots.Single(s => s.Hole.Id == currentShot.Hole.Id && s.Points > 0);

                                // This is a regular steal
                                currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypeSteal);
                                currentShot.Points   = playerWithPoints.Points;

                                // Reset the score to zero for the player who previously had the points
                                Update(playerWithPoints.Id, 0, allShotTypes.Single(st => st.Id == ShotTypeMake));
                            }
                        }
                    }
                    else
                    {
                        // If it is the first shot on the hole, set type and sum points
                        if (currentShot.ShotMade)
                        {
                            currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypeMake);
                            currentShot.Points   = pointsAvailable;
                        }
                        else
                        {
                            currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypeMiss);
                        }
                    }
                }
                else
                {
                    currentShot.ShotType = allShotTypes.Single(st => st.Id == ShotTypeMiss);
                }
            }

            _shotRepository.Add(currentShot);
        }
コード例 #25
0
        public async void Popular()
        {
            PaginatedList <Shot> popular = await Shot.Popular(perPage : 2);

            Assert.Equal(2, popular.Items.Count);
        }
コード例 #26
0
        public async void Everyone()
        {
            PaginatedList <Shot> everyone = await Shot.Everyone(perPage : 2);

            Assert.Equal(2, everyone.Items.Count);
        }
コード例 #27
0
ファイル: LandGame.cs プロジェクト: mgatland/landoftreasure
        protected override void Initialize()
        {
            InitializeTransform();
            InitializeEffect();

            players   = new List <Player>();
            creatures = new List <Creature>();
            shots     = new List <Shot>();

            EventBasedNetListener listener = new EventBasedNetListener();

            client = new NetManager(listener, hostKey);
            if (Packets.SimulateLatency)
            {
                client.SimulateLatency            = true;
                client.SimulationMinLatency       = Packets.SimulationMinLatency;
                client.SimulationMaxLatency       = Packets.SimulationMaxLatency;
                client.SimulatePacketLoss         = Packets.SimulatePacketLoss;
                client.SimulationPacketLossChance = Packets.SimulationPacketLossChance;
            }
            client.Start();
            client.Connect(host, hostPort);
            listener.NetworkReceiveEvent += (fromPeer, dataReader) =>
            {
                byte packetType = dataReader.GetByte();
                if (packetType == Packets.WelcomeClient)
                {
                    this.Id         = dataReader.GetInt();
                    serverStartTick = dataReader.GetLong();
                    player          = new Player(-1);
                    player.X        = dataReader.GetInt();
                    player.Y        = dataReader.GetInt();
                    stopwatch.Restart();
                }
                if (packetType == Packets.Ping)
                {
                    NetDataWriter writer = new NetDataWriter();
                    writer.Put(Packets.Pong);
                    writer.Put(dataReader.GetLong());
                    client.GetFirstPeer().Send(writer, SendOptions.Unreliable);
                }
                if (packetType == Packets.Snapshot)
                {
                    var snapshot = Snapshot.Deserialize(dataReader);
                    //check it's not a duplicate, or stale
                    if (snapshot.Timestamp > latestSnapshotTimestamp)
                    {
                        latestSnapshotTimestamp = snapshot.Timestamp;
                        snapshots.Add(snapshot);
                        //immediately process the ack
                        ProcessClientMovementAck(snapshot.LastAckedClientMove);
                    }
                }
                if (packetType == Packets.Shot)
                {
                    int id   = dataReader.GetInt();
                    var shot = shots.Find(p => p.Id == id);
                    if (shot == null)
                    {
                        Debug.WriteLine("Adding shot {0}", id);
                        shot    = new Shot();
                        shot.Id = id;
                        shots.Add(shot);
                    }
                    shot.SpawnTime = dataReader.GetLong();
                    shot.X         = dataReader.GetInt();
                    shot.Y         = dataReader.GetInt();
                    shot.Angle     = dataReader.GetFloat();
                }
                if (packetType == Packets.Message)
                {
                    Debug.WriteLine("We got: {0}", dataReader.GetString(100 /* max length of string */), "");
                }
            };
            base.Initialize();
        }
コード例 #28
0
 public void ReturnShot(Shot s)
 {
     pool.ReturnObject(s);
 }
コード例 #29
0
ファイル: ScanPoint.cs プロジェクト: JaylinLee/EDMSuite
        private double Calibration(ArrayList shots, int index)
        {
            Shot s = (Shot)shots[0];

            return(s.Calibration(index));
        }
コード例 #30
0
 /// <summary>
 /// This method is called each time a shot made by your bot misses. This information is useful for
 /// updating your bots mapping information.
 /// </summary>
 /// <param name="shot">The coordinates of the shot that missed.</param>
 public override void ShotMiss(Shot shot)
 {
     base.ShotMiss(shot);
 }
コード例 #31
0
 /// <summary>
 /// This method is called each time a shot made by your bot scores a hit against an enemy ship.
 /// This method is useful for updating your bots mapping information. NOTE: the sunk boolean will
 /// only let your bot know that a ship has been sunk, it does not indicate which ship has been sunk.
 /// </summary>
 /// <param name="shot">The coordinates of the shot that hit</param>
 /// <param name="sunk">Returns true if the shot caused an enemy ship to sink</param>
 public override void ShotHit(Shot shot, bool sunk)
 {
     base.ShotHit(shot, sunk);
 }
コード例 #32
0
 /// <summary>
 /// This method is called each time an opponent controller fires a shot. You can use this method
 /// to record the shots your opponent is making against your bot for your own analysis. This information
 /// is particularly useful for ship placement strategies.
 /// </summary>
 /// <param name="shot"></param>
 public override void OpponentShot(Shot shot)
 {
     base.OpponentShot(shot);
 }
コード例 #33
0
 private double ShotBias(double x, Shot s, Vector3 dir)
 {
     return(Dist(x, dir.magnitude * shotWeight, dir.magnitude * shotSpread, Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg));
 }
コード例 #34
0
 public Model SecondaryShotBulletSetter(Shot s)
 {
     mySecondaryShot = s;
     return(this);
 }
コード例 #35
0
 public bool ShotValid(IDNumber shooter, Shot shot)
 {
     return shot != null &&
         shot.Coordinates < Match.CompiledConfig.FieldSize &&
         shot.Coordinates >= new Coordinates(0, 0) &&
         shooter != shot.Receiver &&
         !Match.Fields[shooter].Shots.Contains(shot) &&
         !Match.Teams[DeadTeam].Members.Contains(shot.Receiver);
 }
コード例 #36
0
 /// <summary>
 /// Add a new shot to the <c>ShotManager</c>.
 /// </summary>
 /// <param name="shot">Reference to the shot.</param>
 public void AddShot(Shot shot)
 {
     _shots.Add(shot);
 }
コード例 #37
0
 // Use this for initialization
 void Start()
 {
     _Shot = GameObject.Find("ShotObject").GetComponent <Shot>();
 }
コード例 #38
0
ファイル: BulletManager.cs プロジェクト: tread06/batterybrawl
 public void AddShot(Shot shot)
 {
     shots.Add(shot);       
 }
コード例 #39
0
        public async void Debuts()
        {
            PaginatedList <Shot> debuts = await Shot.Debuts(perPage : 2);

            Assert.Equal(2, debuts.Items.Count);
        }
コード例 #40
0
ファイル: VideoModel.cs プロジェクト: Silox/UGent-stuff
        // Play a shot
        public void playShot(Shot shot)
        {
            if (m_play != null)
            {
                m_play.PlayShot(shot.StartFrame, shot.EndFrame);

                if (m_State == State.Stopped || m_State == State.Paused)
                {
                    m_play.Start();
                    m_State = State.Playing;
                }
             }
        }
コード例 #41
0
 /// <summary>
 /// Passes the <paramref name="register"/> to the base constructor, stores the parameters, and
 /// generates a <see cref="Event.Message"/>.
 /// </summary>
 /// <param name="register">The <see cref="ControllerRegister"/> creating the <see cref="Shot"/></param>
 /// <param name="opposer">The receiving <see cref="ControllerRegister"/> of the <see cref="Shot"/>.</param>
 /// <param name="shot">The <see cref="Shot"/> created.</param>
 public ControllerHitShipEvent(ControllerID sender, Shot shot)
     : base(sender)
 {
     HitShot = shot;
 }
コード例 #42
0
 /// <summary>
 /// Invoked after a player's shot.
 /// </summary>
 /// <param name="ev">The <see cref="ShotEventArgs"/> instance.</param>
 public static void OnShot(ShotEventArgs ev) => Shot.InvokeSafely(ev);
コード例 #43
0
        static void Shoty()
        {
            Console.WriteLine("1.Szybki ogier" +
                              "\n2.Dance Machina" +
                              "\n3.To twój koniec" +
                              "\n4.6pktPLZ" +
                              "\n5.Wróć");
            switch (Console.ReadLine())
            {
            case "1":
                //szybki obiekt
                Console.Clear();
                NowyNapoj szybki = new Shot();
                szybki = new SzybkiOgier(szybki);
                if (Gracz.WypPortfel() < szybki.ObliczKoszt())
                {
                    Console.Clear();
                    Console.WriteLine("Masz za mało hajsiku :(, idź do pracy");
                    Thread.Sleep(2300);
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("{0}, płacisz {1} zł, dochodzi do Cb {2} promila.", szybki.Nazwa(), szybki.ObliczKoszt(), szybki.ObliczPromile());
                    Gracz.ZmianaPortfela(-szybki.ObliczKoszt());
                    Gracz.ZmianaPromili(szybki.ObliczPromile());
                }

                Console.WriteLine("\n Aby kontynuować wciśnij klawisz");
                Console.ReadKey();
                WyborNapoju();
                break;

            case "2":
                //dance obiekt
                Console.Clear();
                NowyNapoj dance = new Shot();
                dance = new DanceMachina(dance);
                if (Gracz.WypPortfel() < dance.ObliczKoszt())
                {
                    Console.Clear();
                    Console.WriteLine("Masz za mało hajsiku :(, idź do pracy");
                    Thread.Sleep(2300);
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("{0}, płacisz {1} zł", dance.Nazwa(), dance.ObliczKoszt());
                    Gracz.ZmianaPortfela(-dance.ObliczKoszt());
                    Gracz.ZmianaPromili(dance.ObliczPromile());
                }

                Console.WriteLine("\n Aby kontynuować wciśnij klawisz");
                Console.ReadKey();
                WyborNapoju();
                break;

            case "3":
                //koniec obiekt
                Console.Clear();
                NowyNapoj koniec = new Shot();
                koniec = new ToTwojKoniec(koniec);
                if (Gracz.WypPortfel() < koniec.ObliczKoszt())
                {
                    Console.Clear();
                    Console.WriteLine("Masz za mało hajsiku :(, idź do pracy");
                    Thread.Sleep(2300);
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("{0}, płacisz {1} zł", koniec.Nazwa(), koniec.ObliczKoszt());
                    Gracz.ZmianaPortfela(-koniec.ObliczKoszt());
                    Gracz.ZmianaPromili(koniec.ObliczPromile());
                }

                Console.WriteLine("\n Aby kontynuować wciśnij klawisz");
                Console.ReadKey();
                WyborNapoju();
                break;

            case "4":
                // pkt obiekt
                Console.Clear();
                NowyNapoj pkt = new Shot();
                pkt = new Pkt(pkt);
                if (Gracz.WypPortfel() < pkt.ObliczKoszt())
                {
                    Console.Clear();
                    Console.WriteLine("Masz za mało hajsiku :(, idź do pracy");
                    Thread.Sleep(2300);
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("Kupujesz {0}, płacisz {1} zł", pkt.Nazwa(), pkt.ObliczKoszt());
                    Gracz.ZmianaPortfela(-pkt.ObliczKoszt());
                    Gracz.ZmianaPromili(pkt.ObliczPromile());
                }

                Console.WriteLine("\n Aby kontynuować wciśnij klawisz");
                Console.ReadKey();
                Console.Clear();
                Console.WriteLine("Dobrodzeju. Za 6pkt otrzymujesz Bar.");
                Console.WriteLine("```````````````````````````" +
                                  "\n````````¶¶¶¶¶¶````````¶¶¶¶¶¶ ´´ ´" +
                                  "\n`````´´¶¶¶¶¶¶¶¶¶`````¶¶¶¶¶¶¶¶¶´´´´" +
                                  "\n`````´¶¶¶¶¶¶¶¶¶¶¶¶`¶¶¶¶¶¶¶¶¶¶¶¶´´" +
                                  "\n`````¶¶¶¶¶..Serduszko...¶¶¶¶¶¶¶¶´´´" +
                                  "\n`````¶¶¶¶...Uśmiechu...¶¶¶¶¶¶¶¶¶ ´´´" +
                                  "\n`````¶¶¶¶¶...Radości...¶¶¶¶¶¶¶¶¶´´´" +
                                  "\n`````´¶¶¶¶¶...I...¶¶¶¶¶¶¶¶¶¶¶¶¶´´" +
                                  "\n`````´´´¶¶¶...Przyjaźni...¶¶¶´´´" +
                                  "\n`````´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶´´" +
                                  "\n`````´´´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶´´´" +
                                  "\n`````´´´´´´´´´¶¶¶¶¶¶¶¶´´´" +
                                  "\n`````´´´´´´´´´´´¶¶¶¶´´´");
                //6pkt obiekt
                //budżet + 20000
                Thread.Sleep(2700);
                WyborNapoju();
                break;

            case "5":
                WyborNapoju();
                break;
            }
        }
コード例 #44
0
ファイル: ShotFixture.cs プロジェクト: Felixdev/dogfight2008
 public void Construct()
 {
     Shot shot = new Shot(new Vector2(0, 0), Calc.DegreesToRadians(45), 10, 0);
 }
コード例 #45
0
ファイル: Player.cs プロジェクト: nicolasmr21/NetFootball
    void Update()
    {
        float h = Input.GetAxis("Horizontal"); // get the horizontal axis of the keyboard
        float v = Input.GetAxis("Vertical");   // get the vertical axis of the keyboard

        if (Input.GetKeyDown(KeyCode.F))
        {
            hitting     = true;                // we are trying to hit the ball and aim where to make it land
            currentShot = shotManager.topSpin; // set our current shot to top spin
        }
        else if (Input.GetKeyUp(KeyCode.F))
        {
            hitting = false; // we let go of the key so we are not hitting anymore and this
        }                    // is used to alternate between moving the aim target and ourself

        if (Input.GetKeyDown(KeyCode.E))
        {
            hitting     = true;             // we are trying to hit the ball and aim where to make it land
            currentShot = shotManager.flat; // set our current shot to top spin
        }
        else if (Input.GetKeyUp(KeyCode.E))
        {
            hitting = false;
        }

        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            speed = 3;
        }
        else if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            speed = 6;
        }

        if (hitting)                                                                // if we are trying to hit the ball
        {
            aimTarget.Translate(new Vector3(h, 0, 0) * speed * 2 * Time.deltaTime); //translate the aiming gameObject on the court horizontallly
        }


        if ((h != 0 || v != 0))                                                 // if we want to move and we are not hitting the ball
        {
            transform.Translate(new Vector3(h, 0, v) * speed * Time.deltaTime); // move on the court

            float x = transform.position.x;
            float y = transform.position.y;
            float z = transform.position.z;

            if (x < -7)
            {
                transform.position = new Vector3(-7f, y, z);
            }
            if (x > 7.5)
            {
                transform.position = new Vector3(7.5f, y, z);
            }
            if (z > 9)
            {
                transform.position = new Vector3(x, y, 9f);
            }
            if (z < -13.5)
            {
                transform.position = new Vector3(x, y, -13.5f);
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            selfRigidbody.AddForce(0, 10, 0, ForceMode.Impulse);
        }

        if (n == 1)
        {
            score = ball.GetComponent <Ball>().score1;
        }
        else
        {
            score = ball.GetComponent <Ball>().score2;
        }
    }
コード例 #46
0
        public async Task <ActionResult> Index(string AccessCode, string examid, string imagename)
        {
            string username = User.Identity.GetUserId();

            if (examid == null)
            {
                RedirectToAction("Index", "Home");
            }

            //we get the subject code
            string[] idSplit = examid.Split('-');

            if (AccessCode != null)
            {
                Log log = new Log();
                log.Activity = "Attempted Exam Access Code for ExamSession: " + examid;
                log.WhoId    = username;
                log.When     = DateTime.Now;

                db.Logs.AddOrUpdate(log);

                await db.SaveChangesAsync();
            }

            ExamSession exam = new ExamSession();

            exam = (from e in db.ExamSessions where e.ExamId == examid select e).FirstOrDefault();

            Enrollment enroller   = new Enrollment();
            string     enrollerid = User.Identity.GetUserName() + "-" + idSplit[0];

            enroller = (from e in db.Enrollments where e.EnrollmentId == enrollerid select e).FirstOrDefault();

            if (imagename == "")
            {
                ViewData["ExamId"] = examid;
                ViewData["Error"]  = "You have not submitted an image";
                return(View());
            }

            if (enroller == null)
            {
                ViewData["ExamId"] = examid;
                ViewData["Error"]  = "There was an error";
                return(View());
            }

            if (exam == null)
            {
                ViewData["ExamId"] = examid;
                ViewData["Error"]  = "Exam not found";
                return(View());
            }

            if (DateTime.Now.Minute > exam.CodeIssueDateTime.Value.Minute + 6 ||
                (DateTime.Now.Hour > exam.CodeIssueDateTime.Value.Hour))
            {
                ViewData["ExamId"] = examid;
                ViewData["Error"]  = "The last Access Code has expired. " +
                                     "Ask the Invigilator for a new one";
                return(View());
            }
            else
            {
                if (AccessCode != exam.AccessCode)
                {
                    ViewData["ExamId"] = examid;
                    ViewData["Error"]  = "This code is not correct";
                    return(View());
                }
            }


            ViewData["ExamId"] = examid;

            ViewData["AccessCode"] = AccessCode;

            //now we get the subject

            ViewBag.Subject = exam.SubjectId;

            if (AccessCode == exam.AccessCode)
            {
                //getting the amount of pictures he already took
                //stick it to the user to get enrollment
                string enrollment  = User.Identity.GetUserName() + "-" + idSplit[0];
                int    imageAmount = db.Shots.Where(x => x.EnrollmentId == enrollment).Count() + 1;
                //set the file name
                string imageData = enrollment + "_" + imageAmount;
                //creating the file itself
                string[] trimmedImageName = imagename.Split(',');
                byte[]   contents         = Convert.FromBase64String(trimmedImageName[1]);
                System.IO.File.WriteAllBytes(Server.MapPath("/Captures/" + imageData + ".png"), contents);


                //placing location on database
                var UserImageDetails = new Shot
                {
                    EnrollmentId  = enrollment,
                    ImageTitle    = imageData,
                    ImageLocation = "/Captures/" + imageData + ".png",
                    ShotTiming    = DateTime.Now
                };

                //BEGIN we mark the student as present
                Enrollment EnrollmentToChange = db.Enrollments.Find(enrollment);
                EnrollmentToChange.FinalAssessment = Enrollment.Assessment.Present;
                EnrollmentToChange.SessionStatus   = Enrollment.Status.Unchecked;
                //END we mark the student as present

                db.Shots.Add(UserImageDetails);
                db.SaveChanges();

                ViewData["ExamId"] = examid;
                ViewData["Error"]  = "";
                //return RedirectToAction("Index","Snap",new { examid=exam.ExamId} );

                //redirects to a get
                //return RedirectToAction("ExamPage", new { examid=exam.ExamId } );

                List <PaperQuestion> paper = ExamPage(examid);
                return(View(paper));
            }

            return(View());
        }
コード例 #47
0
ファイル: Player.cs プロジェクト: jakkes/OnlineSnake
        public void Hit(int index, Shot src)
        {
            if(index == Points.Length - 1 || index == 0) return;
            if (!Armor)
            {
                if (index < Config.data.BASE_LENGTH)
                {
                    Die(src.Source);
                    src.Die();
                    return;
                }

                var d = new DeadPlayer(Points.Skip(index).ToArray(), this);

                Score -= (int)Math.Floor((double)(Length - index - 1) / 2 / Config.data.FOOD_GROW);
                src.Source.Score += (int)Math.Ceiling((double)(Length - index - 1) / 3 / Config.data.FOOD_GROW);
                Length = index + 1;

                src.Die();

                if (Splitted != null)
                    Splitted(this, d);
            }
            else
            {
                int h = Points[index - 1].HeadingTo(Points[index + 1]);
                src.Heading = h - (src.Heading - h);
                Armor = false;
            }
        }
コード例 #48
0
ファイル: Player.cs プロジェクト: aiclub/Mohawk_Battleship
 /// <summary>
 /// Shoots against an arbitrary player opponent at the specified X and Y coordinates.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public virtual Shot Shoot(int x, int y)
 {
     Shot result = null;
     //            foreach (Team t in Match.Teams)
     //            {
     //                if (!t.MembersPlr.Contains(this) && t.MembersPlr.Count > 0)
     //                {
     //                    result = new Shot(t.MembersPlr.First(), new Coordinates(x, y));
     //                    Shoot(result);
     //                    break;
     //                }
     //            }
     Player opponent = null;
     foreach (Player op in Match.Players)
     {
         if (op == this) continue;
         opponent = op;
     }
     result = new Shot(opponent, new Coordinates(x, y));
     Shoot(result);
     return result;
 }
コード例 #49
0
ファイル: Window.cs プロジェクト: Ico0/TelerikAcademy
 public static void PrintShotOnExit(Shot shot)
 {
     Console.SetCursorPosition(StartScreen.consoleWindowWidth - 2, shot.StartY);
     Console.Write(" ");
 }
コード例 #50
0
 /// <summary>
 /// 被弾した。
 /// 体力の減少などは呼び出し側でやっている。
 /// </summary>
 /// <param name="shot">この敵が被弾したプレイヤーの弾</param>
 public virtual void Damaged(Shot shot)
 {
     // none
 }
コード例 #51
0
 private void Start()
 {
     socket.On("verification", (SocketIOEvent e) => {
         //Log("Verified Connection to Server");
         Manager.Instance.LoadScene("Lobby");
         SignIn();
     });
     socket.On("signin-response", (SocketIOEvent e) => {
         //Log("Successfully Signed In");
         Manager.Instance.gameManager.CreatePlayer();
         signedIn = true;
     });
     socket.On("addplayer", (SocketIOEvent e) =>
     {
         //Log("Enemy Player has Joined the Server");
         Manager.Instance.lobbyManager.AddEnemy(e.data["name"].str);
     });
     socket.On("removeplayer", (SocketIOEvent e) =>
     {
         Manager.Instance.lobbyManager.RemoveEnemy();
     });
     socket.On("enemyready", (SocketIOEvent e) =>
     {
         Manager.Instance.lobbyManager.EnemyReady();
     });
     socket.On("enemyunready", (SocketIOEvent e) =>
     {
         Manager.Instance.lobbyManager.EnemyUnready();
     });
     socket.On("countdown", (SocketIOEvent e) =>
     {
         string name = e.data["name"].str;
         float time  = e.data["time"].n;
         if (name == "lobby")
         {
             Manager.Instance.lobbyManager.Countdown(time);
         }
         if (name == "gamestart")
         {
             Manager.Instance.gameManager.Countdown(time);
         }
         if (name == "turn")
         {
             Manager.Instance.gameManager.TurnCountdown(time);
         }
     });
     socket.On("cancelcountdown", (SocketIOEvent e) =>
     {
         string name = e.data["n"].str;
         Log(name);
         if (name == "lobby")
         {
             Manager.Instance.lobbyManager.CancelCountdown();
         }
         if (name == "gamestart")
         {
             Manager.Instance.gameManager.CancelCountdown();
         }
     });
     socket.On("turnover", (SocketIOEvent e) =>
     {
         Manager.Instance.gameManager.TurnOver();
     });
     socket.On("loadgame", (SocketIOEvent e) =>
     {
         Manager.Instance.LoadScene("Scene1");
     });
     socket.On("startturn", (SocketIOEvent e) =>
     {
         //Log("Starting Turn");
         Manager.Instance.gameManager.CancelCountdown();
         Manager.Instance.gameManager.StartGame();
     });
     socket.On("enemyturn", (SocketIOEvent e) =>
     {
         //Log("Received Enemy Turn");
         List <Vector2> enemyTurn = new List <Vector2>();
         foreach (JSONObject vector in e.data["turn"]["turn"].list)
         {
             enemyTurn.Add(JSONTemplates.ToVector2(vector));
         }
         Shot enemyShot = JSONtoShot(e.data["turn"]["shot"]);
         Manager.Instance.gameManager.EnemyTurn(enemyTurn, enemyShot);
     });
     socket.On("player", (SocketIOEvent e) =>
     {
         playerNo = Convert.ToInt32(e.data["p"].n);
         enemyNo  = Convert.ToInt32(e.data["e"].n);
     });
     socket.On("newround", (SocketIOEvent e) =>
     {
         Manager.Instance.gameManager.ResetRound();
     });
     socket.On("setscore", (SocketIOEvent e) =>
     {
         Manager.Instance.gameManager.SetScore(e.data["p1"].n, e.data["p2"].n);
     });
     socket.On("endturn", (SocketIOEvent e) =>
     {
         Manager.Instance.gameManager.OnClick_EndTurn();
     });
     socket.On("endgame", (SocketIOEvent e) =>
     {
         Debug.Log("Ending game: " + signedIn);
         if (Manager.Instance.currentScene == "Scene1")
         {
             Manager.Instance.LoadScene("Lobby");
             Manager.Instance.ErrorMessage(e.data["message"].str);
         }
     });
     socket.On("", (SocketIOEvent e) =>
     {
     });
 }
コード例 #52
0
 public ShotRecord(IBattleshipDbContext context)
 {
     _context = context;
     _shot    = new Shot();
 }
コード例 #53
0
        // From DarthShipBrain
        private bool IsNotMyShot(Shot shot)
        {
            var angleToShot = shot.Forward.GetAngle(spaceship.Forward);

            return(-MyShotLimit > angleToShot || angleToShot > MyShotLimit);
        }
コード例 #54
0
ファイル: Cannon.cs プロジェクト: GinsiderOaks/open-nacer
    public void Shoot(SpaceCraft craft)
    {
        Shot shotInstance = Instantiate <Shot> (shotPrefab, transform.position, transform.rotation);

        shotInstance.owner = craft;
    }
コード例 #55
0
 public Model FocusBulletSetter(Shot s)
 {
     myFocusShot = s;
     return(this);
 }
コード例 #56
0
ファイル: Player.cs プロジェクト: aiclub/Mohawk_Battleship
 /// <summary>
 /// Shoots a shot for the player.
 /// </summary>
 /// <param name="shot"></param>
 public virtual void Shoot(Shot shot)
 {
     InvokeEvent(new PlayerShotEvent(this, shot));
 }
コード例 #57
0
 private void SetBallVisuals(int index, Shot.ShotParams param)
 {
     balls[2].GetComponent<Image>().color = param.GetColor();
 }
コード例 #58
0
 /**
  * Method to save a shoot (the shoot was destroyed)
  */
 public void SaveShoot(Shot shot) => shotsToUse.Add(shot);
コード例 #59
0
ファイル: BulletManager.cs プロジェクト: tread06/batterybrawl
 public void RemoveShot(Shot shot)
 {
     shots.Remove(shot);
 }
コード例 #60
0
 public void DetachLine(Shot shot)
 {
     RequeueLine(activeShotLines[shot]);
     activeShotLines.Remove(shot);
 }