コード例 #1
0
        private void TriggerDetection()
        {
            int count = this._triggers.Count;

            for (int i = 0; i < count; i++)
            {
                ITrigger trigger = this._triggers[i];
                Fix64    r       = trigger.triggerRadius * trigger.triggerRadius;
                this._battle.maze.GetTileObjectsAround(trigger.tileIndex, ref this._championsAround);
                int      c2       = this._championsAround.Count;
                Champion champion = null;
                Fix64    min      = Fix64.MaxValue;
                for (int j = 0; j < c2; j++)
                {
                    ITileObject tileObject = this._championsAround[j];
                    if (!(tileObject is Champion))
                    {
                        continue;
                    }

                    Fix64 d = tileObject.position.DistanceSquared(trigger.position);
                    if (d <= r && d < min)
                    {
                        champion = ( Champion )tileObject;
                        min      = d;
                    }
                }
                if (champion != null)
                {
                    trigger.OnTrigger(champion);
                    --i;
                    --count;
                }
                this._championsAround.Clear();
            }
        }