예제 #1
0
    public void Initialize(Helper gameboardHelper)
    {
        _gameboardHelper = gameboardHelper;

        Hazards = gameObject.AddComponent <TileHazards>();
        Hazards.Initialize(this, _gameboardHelper);

        _stateHandlers.Add(Hazards);
    }
예제 #2
0
 public Trainer(String name, int playerNumber, Set[] pokemons)
 {
     this.name             = name;
     this.pokemons         = pokemons;
     this._indexPokemonOut = 0;
     this.NextAction       = "...";
     this.hazards          = Hazards.None;
     this.playerNumber     = playerNumber;
 }
예제 #3
0
        /// <summary>
        /// Raycast against all hazards
        /// </summary>
        /// <param name="ray"></param>
        /// <param name="distance"></param>
        /// <returns></returns>
        public static HazardHit RaycastHazards(Ray ray, float distance = 10)
        {
            ray.direction = new Vector3(ray.direction.x, 0, ray.direction.z).normalized;

            HazardHit hit       = new HazardHit();
            bool      hitted    = false;
            bool      insideOOB = false;

            List <HazardBase> hazards = Hazards;

            for (int i = 0; i < hazards.Count; ++i)
            {
                HazardHit temp = new HazardHit();
                if (hazards[i].Raycast(ray, temp, distance))
                {
                    switch (temp.type)
                    {
                    case HazardBase.Type.Out_of_Bounds:
                        insideOOB = true;
                        break;

                    default:
                        hitted = true;
                        hit    = temp;
                        break;
                    }
                }
            }

            if (hitted)
            {
                return(hit);
            }
            else
            {
                if (insideOOB)
                {
                    return(hit);
                }
                else
                {
                    Layer layer = CourseBase.GetLayer(Utility.GetName(HazardBase.Type.Out_of_Bounds), CourseBase.HazardLayers);
                    if (Hazards.Find(x => x.Layer == layer))
                    {
                        hit.type       = HazardBase.Type.Out_of_Bounds;
                        hit.InstanceID = Hazards.Find(x => x.Layer == layer).Info.InstanceID;
                        return(hit);
                    }
                    else
                    {
                        hit.type = HazardBase.Type.Out_of_Bounds;
                        return(hit);
                    }
                }
            }
        }
예제 #4
0
 static void CheckHideFlags(HideFlags hideFlags = HideFlags.HideInHierarchy)
 {
     Curves.ForEach(x => x.gameObject.hideFlags   = hideFlags);
     Hazards.ForEach(x => x.gameObject.hideFlags  = hideFlags);
     Tees.ForEach(x => x.gameObject.hideFlags     = hideFlags);
     Shots.ForEach(x => x.gameObject.hideFlags    = hideFlags);
     Pins.ForEach(x => x.gameObject.hideFlags     = hideFlags);
     Measures.ForEach(x => x.gameObject.hideFlags = hideFlags);
     FlyBys.ForEach(x => x.gameObject.hideFlags   = hideFlags);
 }
예제 #5
0
        public void Register(Hazard hazard)
        {
            Hazards.Add(hazard);
            hazard.transform.SetParent(transform, true);

            hazard.OnHazardChanged   += OnHazardChanged;
            hazard.OnHazardDestroyed += OnHazardDestroyed;

            OnChunkChanged.Raise(this);
        }
예제 #6
0
 public void beginGame()
 {
     gui   = new GUI();
     c     = new Cave();
     pc    = new PlayerControl();
     gl    = new GameLocations();
     h     = new Hazards();
     t     = new Trivia();
     hs    = new HighScore();
     turns = 0;
 }
예제 #7
0
 private void OnHazardChanged(Hazard hazard)
 {
     if (!Hazards.Contains(hazard))
     {
         throw new InvalidOperationException($"Attempted to updated hazard `{hazard}` but it could not be found!");
     }
     else
     {
         OnChunkChanged.Raise(this);
     }
 }
예제 #8
0
        private void OnHazardDestroyed(Hazard hazard)
        {
            if (Hazards.Contains(hazard))
            {
                Hazards.Remove(hazard);
                _log.Info($"Hazard {hazard} has been removed.");
            }
            else
            {
                throw new InvalidOperationException($"Attempted to remove hazard {hazard} but it could not be found!");
            }

            hazard.OnHazardChanged   -= OnHazardChanged;
            hazard.OnHazardDestroyed -= OnHazardDestroyed;

            OnChunkChanged.Raise(this);
        }
예제 #9
0
 public Fireball(Level l, Point position, Sprite sprite, Sprite deathsprite, Hazards type) : base(l, position, sprite, deathsprite)
 {
     timer = 70;
     Type  = type;
     if (Type == Hazards.FirebarFireball)
     {
         BoundingBox = new Bounds(this, Color.Pink, new Vector2(2, 2), new Vector2(4, 4));
         HasGravity  = false;
         Velocity    = Vector2.Zero;
     }
     else
     {
         BoundingBox = new Bounds(this, Color.Pink, new Vector2(-1, -1), new Vector2(10, 10));
         HasGravity  = true;
         Velocity    = new Vector2((l.Mario.Flipped ? 1 : -1) * 3, 0);
         Velocity   += Level.Mario.Position - Level.Mario.PrevPosition;
         Flipped     = l.Mario.Flipped;
     }
 }
예제 #10
0
 public void RemoveHazards()
 {
     this.hazards = Hazards.None;
 }
예제 #11
0
 public void RemoveHazards(params Hazards[] hazards)
 {
     this.hazards &= hazards.Aggregate((Hazards s, Hazards c) => s | ~c);
 }
예제 #12
0
 public void AddHazards(params Hazards[] hazards)
 {
     this.hazards |= hazards.Aggregate((Hazards s, Hazards c) => s | c);
 }
 /// <summary>
 ///   Creates a new object that is a copy of the current instance.
 /// </summary>
 ///
 /// <returns>
 ///   A new object that is a copy of this instance.
 /// </returns>
 ///
 public override object Clone()
 {
     return(new EmpiricalHazardDistribution((double[])Times.Clone(), (double[])Hazards.Clone(), estimator));
 }