Esempio n. 1
0
    /// <summary>
    /// 通知播放动画 点击动画
    /// </summary>
    /// <param name="type"></param>
    protected virtual void NotifyPlayAnim(HitLocation type)
    {
        if (_isPlayingAnim)
        {
            return;
        }

        switch (type)
        {
        case HitLocation.Loc_Hair:
            PlayRoleAnim(PlayerAnimDirection.Down, PlayerAnimType.Hair, true);
            break;

        case HitLocation.Loc_Clothes:
            PlayRoleAnim(PlayerAnimDirection.Down, PlayerAnimType.Clothes, true);
            break;

        case HitLocation.Loc_Bottoms:
            PlayRoleAnim(PlayerAnimDirection.Down, PlayerAnimType.Bottoms, true);
            break;

        default:
            PlayRandomAnim();
            break;
        }
    }
Esempio n. 2
0
 public PlayerDiedEventArgs(Player player, Player killer, MeansOfDeath meansOfDeath, HitLocation hitLocation)
     : base(player)
 {
     Location = hitLocation;
     MeansOfDeath = meansOfDeath;
     Killer = killer;
 }
Esempio n. 3
0
        private void ApplyBionics(HitLocation hitLocation, PlayerSoldier soldier)
        {
            // NOTE: We don't heal the wound here.
            // The wound will heal automatically in the next turn.
            // This represents the marine learning how to use the new body part.
            hitLocation.IsCybernetic = true;
            soldier.AddEntryToHistory($"Received bioic {hitLocation.Template.Name} replacement");

            if (hitLocation.Template.Name.Contains("Arm"))
            {
                hitLocation.Armor = 2;
                string otherName        = hitLocation.Template.Name.Replace("Arm", "Hand");
                var    otherHitLocation = soldier.Body.HitLocations
                                          .First(hl => hl.Template.Name == otherName);
                otherHitLocation.Armor        = 2;
                otherHitLocation.IsCybernetic = true;
            }
            else if (hitLocation.Template.Name.Contains("Leg"))
            {
                hitLocation.Armor = 3;
                string otherName        = hitLocation.Template.Name.Replace("Leg", "Foot");
                var    otherHitLocation = soldier.Body.HitLocations
                                          .First(hl => hl.Template.Name == otherName);
                otherHitLocation.Armor        = 3;
                otherHitLocation.IsCybernetic = true;
            }
        }
        // Initialize variables
        private void InitVariables()
        {
            this.tableLevel  = GlobalClass.tableHeight;
            this.netLocation = GlobalClass.netLocation;

            this._xyData        = new List <KeyValuePair <float, float> >();
            this.AllData        = new List <DataPoint>();
            this.Bounces        = new List <HitLocation>();
            this.startLocation  = new DataPoint(0, 0, 0, 0);
            this.tempBounceXYZ  = new HitLocation();
            this.Direction      = "";
            this.VertDir        = "";
            this.bounce1        = false;
            this.serveBounce    = false;
            this.served         = false;
            this.inVolley       = false;
            this.hitTime        = DateTime.MinValue;
            this.startPosition  = false;
            this.startPosTime   = DateTime.MinValue;
            this.PossibleBounce = false;
            PossibleNet         = false;
            this.scoreDelay     = DateTime.MinValue;
            Server         = "";
            VolleyHits     = 0;
            VolleyNumber   = 1;
            maxSpeed       = 0;
            pause          = false;
            SpeedData      = new string[10000];
            SpeedIndex     = 0;
            wrongServeTime = DateTime.MinValue;
        }
Esempio n. 5
0
    /// <summary>
    /// 点击角色部位检测
    /// </summary>
    public void DoRaycast()
    {
        // Cast ray from pointer position.
//        var pos = Vector3.zero;
//#if UNITY_EDITOR
//        pos = Input.mousePosition;
//#else
//        pos = Input.touches[0].deltaPosition;
//#endif
        var ray      = Camera.main.ScreenPointToRay(Input.mousePosition);
        var hitCount = Raycaster.Raycast(ray, Results);


        // Return early if nothing was hit.
        if (hitCount == 0)
        {
            return;
        }

        if (_doRaycastNameList.Length <= 0)
        {
            return;
        }

        //Results[i].Drawable.name
        for (int i = 0; i < hitCount; i++)
        {
            HitLocation type = FindDrawableNamaInDoRaycastNameList(Results[i].Drawable.name);
            if (type != HitLocation.Loc_None)
            {
                _notifyPlayAnim?.Invoke(type);
                return;
            }
        }
    }
Esempio n. 6
0
    /// <summary>
    /// 通知播放动画 1.头部 2.身体3.腿部
    /// </summary>
    /// <param name="type"></param>
    protected override void NotifyPlayAnim(HitLocation type)
    {
        if (_isPlayingAnim)
        {
            return;
        }

        List <PlayerAnimType> randomAnim = new List <PlayerAnimType>();

        switch (type)
        {
        case HitLocation.Loc_Hair: randomAnim.AddRange(_randomAnimTouchHairList); break;

        case HitLocation.Loc_Clothes: randomAnim.AddRange(_randomAnimTouchClothesList); break;

        case HitLocation.Loc_Bottoms: randomAnim.AddRange(_randomAnimTouchBottomsList); break;

        default: randomAnim.AddRange(_randomAnimTouchHairList); break;
        }

        int index = 0;

        if (randomAnim.Count > 1)
        {
            index = Random.Range(0, randomAnim.Count);
        }

        PlayRoleAnim(PlayerAnimDirection.Down, randomAnim[index], true);
    }
Esempio n. 7
0
        private Dictionary <int, List <HitLocation> > GetHitLocationsBySoldierId(IDbConnection connection,
                                                                                 IReadOnlyDictionary <int, HitLocationTemplate> hitLocationTemplateMap)
        {
            Dictionary <int, List <HitLocation> > hitLocationMap = new Dictionary <int, List <HitLocation> >();
            IDbCommand command = connection.CreateCommand();

            command.CommandText = "SELECT * FROM HitLocation";
            var reader = command.ExecuteReader();

            while (reader.Read())
            {
                int         soldierId             = reader.GetInt32(0);
                int         hitLocationTemplateId = reader.GetInt32(1);
                bool        isCybernetic          = reader.GetBoolean(2);
                float       armor          = (float)reader[3];
                int         woundTotal     = reader.GetInt32(4);
                int         weeksOfHealing = reader.GetInt32(5);
                HitLocation hitLocation    =
                    new HitLocation(hitLocationTemplateMap[hitLocationTemplateId],
                                    isCybernetic, armor, (uint)woundTotal, (uint)weeksOfHealing);

                if (!hitLocationMap.ContainsKey(soldierId))
                {
                    hitLocationMap[soldierId] = new List <HitLocation>();
                }
                hitLocationMap[soldierId].Add(hitLocation);
            }
            return(hitLocationMap);
        }
Esempio n. 8
0
 public WoundResolution(BattleSoldier inflicter, WeaponTemplate weapon, BattleSoldier sufferer, float damage, HitLocation hitLocation)
 {
     Inflicter   = inflicter;
     Weapon      = weapon;
     Suffererer  = sufferer;
     Damage      = damage;
     HitLocation = hitLocation;
 }
Esempio n. 9
0
        public void DeleteHitLocation(int id)
        {
            HitLocation hitLocationToBeDeleted = (from h in _repo.Query <HitLocation>()
                                                  where h.Id == id
                                                  select h).FirstOrDefault();

            _repo.Delete(hitLocationToBeDeleted);
        }
Esempio n. 10
0
        public void AddHitLocation(HitLocation newHitLocation)
        {
            Game currentGame = (from g in _repo.Query <Game>()
                                where g.Id == newHitLocation.Game.Id
                                select g).FirstOrDefault();

            newHitLocation.Game = currentGame;

            _repo.Add(newHitLocation);
        }
        static Dictionary <VehicleChassisLocations, float> GetLocationDictionary(Vector3 attackerPosition, Vehicle targetVehicle, Vector3 targetPosition, Quaternion targetRotation)
        {
            //Dictionary<ArmorLocation, float> locDir = new Dictionary<ArmorLocation, float>();

            AttackDirection attackDirection   = GetAttackDirection(attackerPosition, targetVehicle, targetPosition, targetRotation);
            HitLocation     hitLocationHelper = targetVehicle.Combat.HitLocation;
            Dictionary <VehicleChassisLocations, int> hitTable = hitLocationHelper.GetVehicleHitTable(attackDirection, false);

            return(HitTableToLocationDirectory(hitTable));
        }
        static AttackDirection GetAttackDirection(Vector3 attackerPosition, AbstractActor targetActor, Vector3 targetPosition, Quaternion targetRotation)
        {
            if (targetActor.IsProne)
            {
                return(AttackDirection.ToProne);
            }

            HitLocation hitLocationHelper = targetActor.Combat.HitLocation;

            return(hitLocationHelper.GetAttackDirection(attackerPosition, targetPosition, targetRotation));
        }
Esempio n. 13
0
 /// <summary>
 /// 角色点击回调
 /// </summary>
 /// <param name="type"></param>
 protected void PlayerClickCallback(HitLocation type)
 {
     Debug.Log("角色点击回调 type =" + type);
     if (_roleTouchIsPlayAnim)
     {
         NotifyPlayAnim(type);
     }
     else
     {
         PlayerTouchEvent(type);
     }
 }
        static Dictionary <ArmorLocation, float> GetLocationDictionary(Vector3 attackerPosition, Mech m, Vector3 targetPosition, Quaternion targetRotation)
        {
            //Dictionary<ArmorLocation, float> locDir = new Dictionary<ArmorLocation, float>();

            // TODO handle called shots - see HitLocationRules.cs GetAdjacentHitLocation

            AttackDirection attackDirection          = GetAttackDirection(attackerPosition, m, targetPosition, targetRotation);
            HitLocation     hitLocationHelper        = m.Combat.HitLocation;
            Dictionary <ArmorLocation, int> hitTable = hitLocationHelper.GetMechHitTable(attackDirection, false);

            return(HitTableToLocationDirectory(hitTable));
        }
Esempio n. 15
0
        public void UpdateHitLocation(HitLocation updatedHitLocation)
        {
            HitLocation originalHitLocation = (from h in _repo.Query <HitLocation>()
                                               where h.Id == updatedHitLocation.Id
                                               select h).FirstOrDefault();

            originalHitLocation.X       = updatedHitLocation.X;
            originalHitLocation.Y       = updatedHitLocation.Y;
            originalHitLocation.Z       = updatedHitLocation.Z;
            originalHitLocation.Volley  = updatedHitLocation.Volley;
            originalHitLocation.Game.Id = updatedHitLocation.Game.Id;

            _repo.SaveChanges();
        }
Esempio n. 16
0
        private void HandleHit()
        {
            HitLocation hitLocation = DetermineHitLocation(_target);

            // make sure this body part hasn't already been shot off
            if (!hitLocation.IsSevered)
            {
                float damage         = BattleModifiersUtil.CalculateDamageAtRange(_weapon, _range) * (3.5f + ((float)RNG.NextGaussianDouble() * 1.75f));
                float effectiveArmor = _target.Armor.Template.ArmorProvided * _weapon.Template.ArmorMultiplier;
                float penDamage      = damage - effectiveArmor;
                if (penDamage > 0)
                {
                    float totalDamage = penDamage * _weapon.Template.WoundMultiplier;
                    _resultList.Add(new WoundResolution(_soldier, _weapon.Template, _target, totalDamage, hitLocation));
                }
            }
        }
Esempio n. 17
0
        private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            MouseHitLocation = SetHitType(rectangleCropVideo, Mouse.GetPosition(canvasCropVideo));
            SetMouseCursor();
            if (MouseHitLocation == HitLocation.None)
            {
                return;
            }

            LastPoint  = Mouse.GetPosition(canvasCropVideo);
            isDragging = true;
            Storyboard storyboardIn = FindResource("mediaControlsAnimationOut") as Storyboard;

            Storyboard.SetTarget(storyboardIn, gridSourceControls);
            storyboardIn.Completed += (s, _e) => { gridSourceControls.IsHitTestVisible = false; };
            if (gridSourceControls.Opacity == 1)
            {
                storyboardIn.Begin();
            }
        }
Esempio n. 18
0
		private void menuInsertReportItem(HitLocation hl, string reportItem)
		{
			_Undo.StartUndoGroup("Insert");
            try
            {
                if (hl.HitContainer.Name == "Table" || hl.HitContainer.Name == "fyi:Grid")
                {
                    _DrawPanel.ReplaceReportItems(hl, reportItem);
                }
                else
                    _DrawPanel.PasteReportItems(hl.HitContainer, reportItem, hl.HitRelative);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Internal error: illegal insert syntax:" + Environment.NewLine + 
                    reportItem + Environment.NewLine + ex.Message);
                return;
            }
            finally
            {
                _Undo.EndUndoGroup(true);
            }
			_DrawPanel.Invalidate();
			ReportChanged(this, new EventArgs());
			SelectionChanged(this, new EventArgs());
			ReportItemInserted(this, new EventArgs());

            if (reportItem.Contains("<System.Drawing.Image") || reportItem.Contains("<Subreport"))
	    		menuProperties_Click();     // bring up report dialog for images and subreports
		}
Esempio n. 19
0
		private bool DrawPanelMouseDownInsert(HitLocation hl, object sender, MouseEventArgs e)
		{
			if (!(_CurrentInsert != null &&		// should we be inserting?
				_MouseDownNode != null &&			
				(_MouseDownNode.Name == "List" ||
				_MouseDownNode.Name == "System.Drawing.Rectangle" ||
				_MouseDownNode.Name == "Body" ||
				_MouseDownNode.Name == "PageHeader" ||
				_MouseDownNode.Name == "PageFooter")))
			{
				if (_CurrentInsert == null || _CurrentInsert == "Line" || hl == null || 
						hl.HitContainer == null || (!(hl.HitContainer.Name == "Table" || hl.HitContainer.Name=="fyi:Grid")))
				   return false;
				
				if (MessageBox.Show("Do you want to replace contents of TableCell?", "Insert", MessageBoxButtons.YesNo) != DialogResult.Yes)
					return false;
			}
			switch (_CurrentInsert)
			{
				case "Textbox":
					menuInsertTextbox_Click(sender, e);
					break;
				case "Chart":
					menuInsertChart_Click(sender, e);
					break;
				case "System.Drawing.Rectangle":
					menuInsertRectangle_Click(sender, e);
					break;
				case "Table":
                case "fyi:Grid":
                    menuInsertTable_Click(sender, e);
					break;
                case "Matrix":
					menuInsertMatrix_Click(sender, e);
					break;
				case "List":
					menuInsertList_Click(sender, e);
					break;
				case "Line":
					menuInsertLine_Click(sender, e);
					break;
				case "System.Drawing.Image":
					menuInsertImage_Click(sender, e);
					break;
				case "Subreport":
					menuInsertSubreport_Click(sender, e);
					break;
				default:
					break;
			}
			return true;
		}
Esempio n. 20
0
        // Color frame analysis With ball action analysis
        private void Frame_Arrived(object sender, MultiSourceFrameArrivedEventArgs e)
        {
            bool changeDir = false;


            if (scoreDelay != DateTime.MinValue)
            {
                if ((float)DateTime.Now.Subtract(this.scoreDelay).TotalSeconds < 2)
                {
                    pause = true;
                }
                else
                {
                    scoreDelay = DateTime.MinValue;
                    pause      = false;
                }
            }

            if (!gameOver && !pause)
            {
                MultiSourceFrame multiSourceFrame = e.FrameReference.AcquireFrame();

                if (inVolley)
                {
                    // If too much time passes without bounce/return, someone missed
                    if (this.hitTime != DateTime.MinValue)
                    {
                        if ((float)DateTime.Now.Subtract(this.hitTime).TotalSeconds > 1.5)
                        {
                            if (this.Direction == "Left" && bounce1)
                            {
                                Score("P2", "Time Limit - no return");
                            }
                            else if (this.Direction == "Left")
                            {
                                Score("P1", "Time Limit - no bounce");
                            }
                            else if (this.Direction == "Right" && bounce1)
                            {
                                Score("P1", "Time Limit - no return");
                            }
                            else
                            {
                                Score("P2", "Time Limit - no bounce");
                            }
                        }
                    }

                    // Get Ball xy coordinates
                    DataPoint BallLocation = FindBall(multiSourceFrame);
                    int       xavg         = (int)BallLocation.X;
                    int       yavg         = (int)BallLocation.Y;

                    // Check if location seems reasonable, set xavg to 1 (default no ball found value) if not
                    if (AllData.Count > 0)
                    {
                        if (!ReasonableLocation(BallLocation))
                        {
                            xavg = 1;
                        }
                    }

                    // If good data point, analyze it
                    if (xavg > 1)
                    {
                        // Get ball xyz coordinates
                        using (DepthFrame depthFrame = multiSourceFrame.DepthFrameReference.AcquireFrame())
                        {
                            CurrentXYZ = XYZLocation(depthFrame, xavg, yavg);
                        }

                        // Off (or rather under) table
                        if (yavg < tableLevel - 100)
                        {
                            if (bounce1)
                            {
                                if (this.Direction == "Left")
                                {
                                    Score("P2", "Below Table - no return");
                                }
                                else
                                {
                                    Score("P1", "Below Table - no return");
                                }
                            }
                            else if (served)
                            {
                                if (this.Direction == "Left")
                                {
                                    Score("P1", "Below Table - no bounce");
                                }
                                else
                                {
                                    Score("P2", "Below Table - no bounce");
                                }
                            }
                            else
                            {
                                ServeIsBad();
                            }
                        }

                        // Determine direction and do game processing
                        float xdelta = 0;
                        float ydelta = 0;
                        if (AllData.Count > 0)
                        {
                            xdelta = AllData[AllData.Count - 1].X - xavg;
                            ydelta = AllData[AllData.Count - 1].Y - yavg;
                        }

                        if (served)
                        {
                            // Horizontal direction determination and direction change detection
                            if (xdelta > 10)
                            {
                                if (this.Direction == "Right")
                                {
                                    ChangeDirection(ydelta);
                                    changeDir = true;
                                }
                                this.Direction = "Left";
                                PossibleNet    = false;
                            }
                            else if (xdelta < -10)
                            {
                                if (this.Direction == "Left")
                                {
                                    ChangeDirection(ydelta);
                                    changeDir = true;
                                }
                                this.Direction = "Right";
                                PossibleNet    = false;
                            }
                            // Check for possible hitting net - two frames at net means a score
                            else if (xavg - netLocation < 20 && xavg - netLocation > 0 && Direction == "Left")
                            {
                                if (PossibleNet)
                                {
                                    Score("P1", "Hit Net");
                                }
                                else
                                {
                                    PossibleNet = true;
                                }
                            }
                            else if (xavg - netLocation > -20 && xavg - netLocation < 0 && Direction == "Right")
                            {
                                if (PossibleNet)
                                {
                                    Score("P2", "Hit Net");
                                }
                                else
                                {
                                    PossibleNet = true;
                                }
                            }

                            // Vertical direction and bounce detection
                            if (ydelta > 5)
                            {
                                this.VertDir   = "Down";
                                PossibleBounce = false;
                            }
                            else if (ydelta < -5)
                            {
                                if (this.VertDir == "Down" && !changeDir && yavg - tableLevel < 100)   // Log possible bounce
                                {
                                    PossibleBounce  = true;
                                    this.hitTime    = DateTime.Now;
                                    this.tempBounce = new DataPoint(xavg, yavg, 0, 0);
                                }
                                else if (PossibleBounce)  // if no direction change one frame later, possible bounce is a bounce
                                {
                                    if (!changeDir)
                                    {
                                        // Handle bounce processing
                                        if (PreviousXYZ.X != 0 && PreviousXYZ.Y != 0 && PreviousXYZ.Z != 0 && PreviousXYZ.Z > GlobalClass.minZ && this.serveBounce)
                                        {
                                            HitLocation bounceXYZ = new HitLocation();
                                            bounceXYZ.X      = PreviousXYZ.X;
                                            bounceXYZ.Y      = PreviousXYZ.Y;
                                            bounceXYZ.Z      = PreviousXYZ.Z;
                                            bounceXYZ.Volley = VolleyNumber;
                                            this.Bounces.Add(bounceXYZ);
                                        }
                                        Bounce(new DataPoint(tempBounce.X, tempBounce.Y, 0, (float)(DateTime.Now.Subtract(this.timeStarted).TotalSeconds)));
                                    }
                                    PossibleBounce = false;
                                }
                                this.VertDir = "Up";
                            }
                            else if (PossibleBounce)
                            {
                                PossibleBounce = false;
                            }
                            else if (ydelta <= 0)
                            {
                                if (this.VertDir == "Down" && !changeDir && yavg - tableLevel < 100)   // Log possible bounce
                                {
                                    PossibleBounce  = true;
                                    this.hitTime    = DateTime.Now;
                                    this.tempBounce = new DataPoint(xavg, yavg, 0, 0);
                                }
                            }
                        }
                        else if (inVolley)    // if not served yet, check for serve hit
                        {
                            // check for low, shallow bounce serve
                            int xStartDelta = 0;
                            if (Server == "P1")
                            {
                                xStartDelta = xavg - (int)startLocation.X;
                            }
                            else
                            {
                                xStartDelta = (int)startLocation.X - xavg;
                            }

                            if (xStartDelta > 50)
                            {
                                served          = true;
                                VolleyStartTime = DateTime.Now;
                                if (ydelta > 10)
                                {
                                    VertDir = "Down";
                                }
                                else if (yavg - tableLevel < 50)
                                {
                                    VertDir     = "Up";
                                    serveBounce = true;
                                }

                                if (xdelta > 0)
                                {
                                    this.Direction = "Left";
                                }
                                else
                                {
                                    this.Direction = "Right";
                                }
                            }

                            // Serve defined as moving in x and negative y (slower serve, easy bounce detection)
                            else if ((xdelta > 10 || xdelta < 10) && ydelta > 10 && xStartDelta > 50)
                            {
                                this.served     = true;
                                VolleyStartTime = DateTime.Now;
                                this.VertDir    = "Down";
                                if (xdelta > 0)
                                {
                                    this.Direction = "Left";
                                }
                                else
                                {
                                    this.Direction = "Right";
                                }
                            }
                        }
                        // Add current location to points list
                        this.AllData.Add(new DataPoint(xavg, yavg, 0, (float)(DateTime.Now.Subtract(this.timeStarted).TotalSeconds)));
                        double currentSpeed = 0;

                        // Check ball speed
                        if (PreviousXYZ != null)
                        {
                            currentSpeed = BallSpeed(CurrentXYZ, PreviousXYZ);
                        }
                        if (currentSpeed > maxSpeed)
                        {
                            maxSpeed = currentSpeed;
                        }
                        PreviousXYZ = CurrentXYZ;
                    }
                }
                else   // Check for ball in start position to start volley
                {
                    // Get Ball xy coordinates
                    DataPoint BallLocation = FindBall(multiSourceFrame);
                    int       xavg         = (int)BallLocation.X;
                    int       yavg         = (int)BallLocation.Y;

                    CheckStartPosition(xavg, yavg);
                }
            }
        }
Esempio n. 21
0
    private IEnumerator OnCharacterColliderEnter(Collider collider)
    {
        GameObject collidedObject = null;

        if (isGameOver == true)
        {
            yield break;
        }

        if (collider.transform.parent != null)
        {
            if (collider.transform.parent.gameObject != null)
            {
                collidedObject = collider.transform.parent.gameObject;
            }
        }

        //-------------------------------------------------------------------------------


        switch (collider.tag)
        {
        case "powerup":

            if (collidedObject != null)
            {
                if (collidedObject.tag == "Coin" || collidedObject.tag == "Banana" || collidedObject.tag == "Pinya")
                {
                    Coin currentCoin = collidedObject.gameObject.GetComponent <Coin>();
                    if (currentCoin != null)
                    {
                        currentCoin.pickUp();
                    }
                }
                if (collidedObject.tag == "Banana")
                {
                    timeBanana = powerupDuration + Time.deltaTime;
                    bananaBool = true;
                }
                if (collidedObject.tag == "Pinya")
                {
                    timePinya = powerupDuration + Time.deltaTime;
                    pinyaBool = true;
                }
            }

            break;

        case "instant-die":
            this.DoStumble(collidedObject, StumbleLocation.FrontMiddle);
            break;

        case "obstacle":

            //Debug.Log(trackMovementLast);
            //Debug.Log(collider.name);

            int lane;

            int[] hits = analizeHit(collider);

            HitLocation tx = (HitLocation)hits[0];
            HitLocation ty = (HitLocation)hits[1];
            HitLocation tz = (HitLocation)hits[2];

            float colliderCenter = (collider.bounds.min.x + collider.bounds.max.x) / 2f;
            float x = player.transform.position.x;


            if (x < colliderCenter)
            {
                lane = 1;
            }
            else if (x > colliderCenter)
            {
                lane = -1;
            }
            else
            {
                lane = 0;
            }

//                Debug.Log(lane);
            bool flag  = (lane == 0) || (trackMovementLast == lane);
            bool flag2 = characterCollider.bounds.center.z < collider.bounds.min.z;
            bool flag3 = ((tz == HitLocation.Before) && !flag2) && flag;

            // Debug.Log(collider.name + " - flag:" + flag + " flag2:" + flag2 + " flag3:" + flag3);



            if ((tz == HitLocation.ZMiddle) || flag3)
            {
                // SIDES

                if (trackMovementLast != 0)
                {
                    // Lane Fix
                    //StopAllCoroutines();
                    StopCoroutine(changeLine);
                    // Debug.Log(changeLine);
                    ForceChangeTrack(-this.trackMovementLast, 0);
                    //player.transform.position = new Vector3(-6, player.transform.position.y, player.transform.position.z);
                    //player.transform.localRotation = Quaternion.Euler(0f, characterRotation, 0f);
                }

                switch (tx)
                {
                case HitLocation.Left:

                    this.DoStumble(collidedObject, StumbleLocation.LeftSide);

                    break;

                case HitLocation.Right:

                    this.DoStumble(collidedObject, StumbleLocation.RightSide);
                    break;
                }
            }
            else if ((tx == HitLocation.XMiddle) || (trackMovementLast == 0))
            {
                if (tz == HitLocation.Before)
                {
                    if (ty == HitLocation.Lower)
                    {
                        //Debug.Log(collider.name + " Front Lower");
                        this.DoStumble(collidedObject, StumbleLocation.FrontLower);
                    }
                    else if (ty == HitLocation.YMiddle)
                    {
                        //Debug.Log(collider.name + " Front Middle");
                        this.DoStumble(collidedObject, StumbleLocation.FrontMiddle);
                    }
                    else if (ty == HitLocation.Upper)
                    {
                        //Debug.Log(collider.name + " Front Upper");
                        this.DoStumble(collidedObject, StumbleLocation.FrontUpper);
                    }
                }
            }
            else
            {
                if (tx == HitLocation.Left && tz == HitLocation.Before)
                {
                    //Debug.Log(collider.name + " Front Left Corner");
                    this.DoStumble(collidedObject, StumbleLocation.FrontLeftCorner);
                }

                if (tx == HitLocation.Right && tz == HitLocation.Before)
                {
                    //Debug.Log(collider.name + " Front Right Corner");
                    this.DoStumble(collidedObject, StumbleLocation.FrontRightCorner);
                }

                if (tx == HitLocation.Left && tz == HitLocation.After)
                {
                    ForceChangeTrack(-this.trackMovementLast, 0.5f);

                    //Debug.Log(collider.name + " Back Left Corner");
                    this.DoStumble(collidedObject, StumbleLocation.BackLeftCorner);
                }

                if (tx == HitLocation.Right && tz == HitLocation.After)
                {
                    ForceChangeTrack(-this.trackMovementLast, 0.5f);

                    //Debug.Log(collider.name + " Back Right Corner");
                    this.DoStumble(collidedObject, StumbleLocation.BackRightCorner);
                }
            }



            break;
        }

        yield break;
    }
Esempio n. 22
0
 /// <summary>
 /// 角色点击事件函数
 /// </summary>
 protected void PlayerTouchEvent(HitLocation type)
 {
     Debug.Log("PlayerTouchEvent 角色点击事件函数 type = " + type);
     TouchPlayerNotPlayAnimCallback?.Invoke(type);
 }
Esempio n. 23
0
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (isDragging)
            {
                // See how much the mouse has moved.
                Point  point    = Mouse.GetPosition(canvasCropVideo);
                double offset_x = point.X - LastPoint.X;
                double offset_y = point.Y - LastPoint.Y;

                // Get the rectangle's current position.
                double new_x      = Canvas.GetLeft(rectangleCropVideo);
                double new_y      = Canvas.GetTop(rectangleCropVideo);
                double new_width  = rectangleCropVideo.Width;
                double new_height = rectangleCropVideo.Height;

                // Update the rectangle.
                switch (MouseHitLocation)
                {
                case HitLocation.Body:
                    new_x += offset_x;
                    new_y += offset_y;
                    break;

                case HitLocation.UpperLeft:
                    new_x      += offset_x;
                    new_y      += offset_y;
                    new_width  -= offset_x;
                    new_height -= offset_y;
                    break;

                case HitLocation.UpperRight:
                    new_y      += offset_y;
                    new_width  += offset_x;
                    new_height -= offset_y;
                    break;

                case HitLocation.LowerRight:
                    new_width  += offset_x;
                    new_height += offset_y;
                    break;

                case HitLocation.LowerLeft:
                    new_x      += offset_x;
                    new_width  -= offset_x;
                    new_height += offset_y;
                    break;

                case HitLocation.Left:
                    new_x     += offset_x;
                    new_width -= offset_x;
                    break;

                case HitLocation.Right:
                    new_width += offset_x;
                    break;

                case HitLocation.Bottom:
                    new_height += offset_y;
                    break;

                case HitLocation.Top:
                    new_y      += offset_y;
                    new_height -= offset_y;
                    break;
                }

                // Keep a minimun size for the rectangle and keep the rectangle inside the canvas
                if (new_x < 0)
                {
                    new_x = 0;
                }
                if (new_y < 0)
                {
                    new_y = 0;
                }
                if (new_width + new_x > canvasCropVideo.ActualWidth)
                {
                    if (MouseHitLocation == HitLocation.Body)
                    {
                        new_x = canvasCropVideo.ActualWidth - new_width;
                    }
                    else
                    {
                        new_width = canvasCropVideo.ActualWidth - new_x;
                    }
                }
                if (new_height + new_y > canvasCropVideo.ActualHeight)
                {
                    if (MouseHitLocation == HitLocation.Body)
                    {
                        new_y = canvasCropVideo.ActualHeight - new_height;
                    }
                    else
                    {
                        new_height = canvasCropVideo.ActualHeight - new_y;
                    }
                }
                if (new_width < RECT_MIN_SIZE)
                {
                    if (MouseHitLocation == HitLocation.Left)
                    {
                        new_x     -= offset_x;
                        new_width += offset_x;
                    }
                    else
                    {
                        new_width = RECT_MIN_SIZE;
                    }
                }
                if (new_height < RECT_MIN_SIZE)
                {
                    if (MouseHitLocation == HitLocation.Top)
                    {
                        new_y      -= offset_y;
                        new_height += offset_y;
                    }
                    else
                    {
                        new_height = RECT_MIN_SIZE;
                    }
                }

                // Update the rectangle.
                Canvas.SetLeft(rectangleCropVideo, new_x);
                Canvas.SetTop(rectangleCropVideo, new_y);
                rectangleCropVideo.Width  = new_width;
                rectangleCropVideo.Height = new_height;

                //Update the integer textboxes
                double cropTop    = new_y * mediaInfo.Height / canvasCropVideo.ActualHeight;
                double cropLeft   = new_x * mediaInfo.Width / canvasCropVideo.ActualWidth;
                double cropBottom = (canvasCropVideo.ActualHeight - new_height - new_y) * mediaInfo.Height / canvasCropVideo.ActualHeight;
                double cropRight  = (canvasCropVideo.ActualWidth - new_width - new_x) * mediaInfo.Width / canvasCropVideo.ActualWidth;
                integerTextBoxCropTop.Value    = (int)cropTop;
                integerTextBoxCropLeft.Value   = (int)cropLeft;
                integerTextBoxCropBottom.Value = (int)cropBottom;
                integerTextBoxCropRight.Value  = (int)cropRight;
                textBlockOutputResolution.Text = $"{(mediaInfo.Width - cropLeft - cropRight).ToString("0")}x{(mediaInfo.Height - cropTop - cropBottom).ToString("0")}";

                // Save the mouse's new location.
                LastPoint = point;
            }
            else
            {
                MouseHitLocation = SetHitType(rectangleCropVideo,
                                              Mouse.GetPosition(canvasCropVideo));
                SetMouseCursor();
            }
        }
Esempio n. 24
0
 /// <summary>
 /// 点击角色
 /// </summary>
 /// <param name="type"></param>
 private async void TouchPlayer(HitLocation type)
 {
     Debug.Log("点击角色 部位类型 type = " + type);
     await StaticData.OpenUIRoleSwitching();
 }
Esempio n. 25
0
		private bool DrawPanelMouseDownInsert(HitLocation hl, object sender, MouseEventArgs e)
		{
			if (!(_CurrentInsert != null &&		// should we be inserting?
				_MouseDownNode != null &&			
				(_MouseDownNode.Name == "List" ||
				_MouseDownNode.Name == "Rectangle" ||
				_MouseDownNode.Name == "Body" ||
				_MouseDownNode.Name == "PageHeader" ||
				_MouseDownNode.Name == "PageFooter")))
			{
				if (_CurrentInsert == null || _CurrentInsert == "Line" || hl == null || 
						hl.HitContainer == null || (!(hl.HitContainer.Name == "Table" || hl.HitContainer.Name=="fyi:Grid")))
				   return false;
				
				if (MessageBox.Show(Strings.DesignCtl_ShowB_WantReplaceCell, Strings.DesignCtl_Show_Insert, MessageBoxButtons.YesNo) != DialogResult.Yes)
					return false;
			}
			switch (_CurrentInsert)
			{
				case "Textbox":
					menuInsertTextbox_Click(sender, e);
					break;
				case "Chart":
					menuInsertChart_Click(sender, e);
					break;
				case "Rectangle":
					menuInsertRectangle_Click(sender, e);
					break;
				case "Table":
                case "fyi:Grid":
                    menuInsertTable_Click(sender, e);
					break;
                case "Matrix":
					menuInsertMatrix_Click(sender, e);
					break;
				case "List":
					menuInsertList_Click(sender, e);
					break;
				case "Line":
					menuInsertLine_Click(sender, e);
					break;
				case "Image":
					menuInsertImage_Click(sender, e);
					break;
				case "Subreport":
					menuInsertSubreport_Click(sender, e);
					break;
				default:
					var types = RdlEngineConfig.GetCustomReportTypes();
					if (types.Contains(_CurrentInsert))
					{
						menuInsertCustomReportItem(sender, e, _CurrentInsert);
					}
					break;
			}
			return true;
		}
Esempio n. 26
0
    private IEnumerator OnCharacterColliderEnter(Collider collider)
    {
        GameObject  collidedObject      = null;
        TrackObject collidedTrackObject = null;

        if (isGameOver == true)
        {
            yield break;
        }

        if (collider.transform.parent != null)
        {
            if (collider.transform.parent.gameObject != null)
            {
                collidedObject      = collider.transform.parent.gameObject;
                collidedTrackObject = collidedObject.GetComponent <TrackObject>();
            }
        }

        //-------------------------------------------------------------------------------
        switch (collider.tag)
        {
        case "ground":

            //Debug.Log("ground hit");
            break;

        case "duckPlace":
            GameGlobals.Instance.cameraController.duckCamera(CameraController.DuckState.duckStart);
            break;

        case "powerup":

            if (collidedTrackObject != null)
            {
                // Handle Track Object
                switch (collidedTrackObject.objectType)
                {
                case TrackObject.ObjectType.PointsSingle:

                    Coin currentCoin = collidedTrackObject.gameObject.GetComponent <Coin>();
                    if (currentCoin != null)
                    {
                        currentCoin.pickUp();
                    }

                    break;
                }

                // Powerups and Pickables
                if (collidedTrackObject.objectGroup == TrackObject.ObjectGroup.PowerUps || collidedTrackObject.objectGroup == TrackObject.ObjectGroup.Pickables)
                {
                    Powerup powerUp = collidedTrackObject.gameObject.GetComponent <Powerup>();
                    if (powerUp != null)
                    {
                        powerUp.pickUp();
                    }
                }
            }

            break;

        case "obstacle":

            //Debug.Log(trackMovementLast);
            //Debug.Log(collider.name);
            PowerupController.instance.SetGolds(-2);
            currentLevelSpeed = 30;

            GameGlobals.Instance.cameraController.Shake();
            playVillainAnimation("run");
            //doPlayerRun();

            if (collidedObject.name.IndexOf("Green") != -1 && collidedObject != null)
            {
                Destroy(collidedObject);
            }

            int lane;

            int[] hits = analizeHit(collider);

            HitLocation tx = (HitLocation)hits[0];
            HitLocation ty = (HitLocation)hits[1];
            HitLocation tz = (HitLocation)hits[2];

            float colliderCenter = (collider.bounds.min.x + collider.bounds.max.x) / 2f;
            float x = player.transform.position.x;


            if (x < colliderCenter)
            {
                lane = 1;
            }
            else if (x > colliderCenter)
            {
                lane = -1;
            }
            else
            {
                lane = 0;
            }

            bool flag  = (lane == 0) || (trackMovementLast == lane);
            bool flag2 = characterCollider.bounds.center.z < collider.bounds.min.z;
            bool flag3 = ((tz == HitLocation.Before) && !flag2) && flag;

            // Debug.Log(collider.name + " - flag:" + flag + " flag2:" + flag2 + " flag3:" + flag3);

            // Train Crash

            if (collider.name.Equals("movingMesh") && flag == true && flag2 == false && flag3 == true)
            {
                this.DoStumble(collidedObject, StumbleLocation.FrontMiddle);
            }


            if ((tz == HitLocation.ZMiddle) || flag3)
            {
                // SIDES

                if (trackMovementLast != 0)
                {
                    // Lane Fix
                    // doChangeLane(-trackMovementLast, laneChangeTime);
                }

                switch (tx)
                {
                case HitLocation.Left:

                    //Debug.Log(collider.name + " Left Side");
                    this.DoStumble(collidedObject, StumbleLocation.LeftSide);

                    break;

                case HitLocation.Right:

                    //Debug.Log(collider.name + " Right Side");
                    this.DoStumble(collidedObject, StumbleLocation.RightSide);
                    break;
                }
            }
            else if ((tx == HitLocation.XMiddle) || (trackMovementLast == 0))
            {
                if (tz == HitLocation.Before)
                {
                    if (ty == HitLocation.Lower)
                    {
                        //Debug.Log(collider.name + " Front Lower");
                        this.DoStumble(collidedObject, StumbleLocation.FrontLower);
                    }
                    else if (ty == HitLocation.YMiddle)
                    {
                        //Debug.Log(collider.name + " Front Middle");
                        this.DoStumble(collidedObject, StumbleLocation.FrontMiddle);
                    }
                    else if (ty == HitLocation.Upper)
                    {
                        //Debug.Log(collider.name + " Front Upper");
                        this.DoStumble(collidedObject, StumbleLocation.FrontUpper);
                    }
                }
            }
            else
            {
                if (tx == HitLocation.Left && tz == HitLocation.Before)
                {
                    //Debug.Log(collider.name + " Front Left Corner");
                    this.DoStumble(collidedObject, StumbleLocation.FrontLeftCorner);
                }

                if (tx == HitLocation.Right && tz == HitLocation.Before)
                {
                    //Debug.Log(collider.name + " Front Right Corner");
                    this.DoStumble(collidedObject, StumbleLocation.FrontRightCorner);
                }

                if (tx == HitLocation.Left && tz == HitLocation.After)
                {
                    ForceChangeTrack(-this.trackMovementLast, 0.5f);

                    //Debug.Log(collider.name + " Back Left Corner");
                    this.DoStumble(collidedObject, StumbleLocation.BackLeftCorner);
                }

                if (tx == HitLocation.Right && tz == HitLocation.After)
                {
                    ForceChangeTrack(-this.trackMovementLast, 0.5f);

                    //Debug.Log(collider.name + " Back Right Corner");
                    this.DoStumble(collidedObject, StumbleLocation.BackRightCorner);
                }
            }

            break;
        }

        yield break;
    }