// Update is called once per frame
 void Update()
 {
     if (shooting == true)
     {
         if (time <= 0)
         {
             ArrowTrap arrow = Instantiate(arrowScript, transform.position, transform.rotation) as ArrowTrap;
             arrow.direction = direction2;
             time            = Random.Range(minTime, maxTime);
         }
     }
 }
Beispiel #2
0
    // finds the nearest ancestor with the ArrowTrap component, and assumes that to be the ArrowTrap construction that this Arrow is a part of
    // then finds all the children (and later descendants) of that ArrowTrap that have a Collider and turns on/off (based on the passed-in ignore) the collion between this arrow and those colliders
    private void IgnoreAllArrowTrapChildren(bool ignore)
    {
        ArrowTrap myTrap = CodeTools.GetComponentFromNearestAncestor <ArrowTrap>(this.gameObject);

        if (myTrap == null)
        {
            Debug.LogError(this.gameObject + " does not have an ancestor that contains the ArrowTrap component.");
            return;
        }

        Component[] colliders = myTrap.gameObject.GetComponentsInChildren <Collider>();

        foreach (Collider col in colliders)
        {
            Physics.IgnoreCollision(col, mc, ignore);
        }
    }
Beispiel #3
0
            public void DebugMap()
            {
                MapBuilder.Explored  = TernaryValue.Unexplored;
                MapBuilder.Lightened = true;

                MapBuilder.Height = 30;
                MapBuilder.Width  = 19;

                //mapBuilder.AddAtom(new Wall(new Coord() { X = 10, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 11, Y = 10 }));
                //mapBuilder.AddAtom(new Wall(new Coord() { X = 12, Y = 10 }));

                // Orc Covering Walls
                for (int x = 9; x < 12; x++)
                {
                    MapBuilder.AddAtom(new Wall(new Coord(x, 10)));
                }
                for (int y = 10; y < 14; y++)
                {
                    MapBuilder.AddAtom(new Wall(new Coord(8, y)));
                }
                // 4 Corners
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = 0, Y = 0
                }));
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = 0, Y = MapBuilder.Height - 1
                }));
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = MapBuilder.Width - 1, Y = 0
                }));
                MapBuilder.AddAtom(new Wall(new Coord()
                {
                    X = MapBuilder.Width - 1, Y = MapBuilder.Height - 1
                }));

                MapBuilder.PlayerInitialPosition = new Coord()
                {
                    X = 1, Y = 1
                };

                MapBuilder.AddAtom(new Gold(10, new Coord(2, 2)));
                MapBuilder.AddAtom(new LongSword(position: new Coord()
                {
                    X = 7, Y = 4
                }));
                MapBuilder.AddAtom(new Leather(position: new Coord()
                {
                    X = 7, Y = 3
                }));
                for (int i = 8; i < 18; i++)
                {
                    for (int j = 4; j < 14; j++)
                    {
                        if (i % 2 == 0)
                        {
                            MapBuilder.AddAtom(new LongSword(position: new Coord()
                            {
                                X = i, Y = j
                            }));
                        }
                        else
                        {
                            MapBuilder.AddAtom(new FlamingLongSword(position: new Coord()
                            {
                                X = i, Y = j
                            }));
                        }
                    }
                }

                var book1 = ItemGenerators.GenerateByBuilderType(typeof(PrayerBookBuilder), position: new Coord(2, 1));

                MapBuilder.AddAtom(book1);

                for (int x = 6; x < 15; x++)
                {
                    for (int y = 6; y < 15; y++)
                    {
                        var stackableItem = new StackItemTest(color: System.Drawing.Color.Blue,
                                                              position: new Coord(x, y),
                                                              uses: Item._UnlimitedUses);
                        MapBuilder.AddAtom(stackableItem);
                    }
                }

                MapBuilder.AddAtom(new WoodenShield(position: Coord.Random(MapBuilder.Width, MapBuilder.Height)));
                var orcBuilder1 = AICharacter.DummyCharacter(typeof(Orc)).Builder;

                orcBuilder1.Position = new Coord(10, 12);
                var orc1 = orcBuilder1.Build();

                MapBuilder.AddAtom(orc1);


                var orcBuilder2 = AICharacter.DummyCharacter(typeof(Orc)).Builder;

                orcBuilder2.Position = new Coord(13, 12);
                var orc2 = orcBuilder2.Build();

                MapBuilder.AddAtom(orc2);

                var book2 = new PrayerBookBuilder().GenerateRandom(Pg.Level.Novice, new Coord());

                var merchantBuilder = new MerchantBuilder();

                merchantBuilder.AddItem(new LongSword());
                merchantBuilder.AddItem(book2);
                for (int i = 0; i < 20; i++)
                {
                    merchantBuilder.AddItem(new Meat());
                }
                merchantBuilder.Position = new Coord(4, 4);

                MapBuilder.AddAtom(merchantBuilder.Build());

                var aTrap = new ArrowTrap(new Coord(7, 7));

                MapBuilder.AddAtom(aTrap);

                currentPg = new PgCreator()
                {
                    God = Gods.Ares
                }.Create();

                //currentPg.Listeners.ForEach(listener => orc1.RegisterListener(listener));
                //currentPg.Listeners.ForEach(listener => orc2.RegisterListener(listener));
            }