Beispiel #1
0
        /// <summary>
        /// activate the tool and fire it's ammo
        /// </summary>
        public void Activate()
        {
            if (!cdHandler.IsOnCooldown())
            {
                JObject ammoObj = Util.Deserialize(Ammo.FilePath);

                Ammo newAmmo = new AmmoFactory().Create(ammoObj, FilePath, entHandler, boundaryStrat, Team, SwinGame.PointAt(0, 0)) as Ammo;
                newAmmo.TeleportTo(RealPos);

                newAmmo.Init(RealPos, Dir, Vel);
                entHandler.Track(newAmmo);
                cdHandler.StartCooldown();
            }
        }
Beispiel #2
0
        public override Component Create(JObject toolObj, string path, IHandlesEntities entHandler, BoundaryStrategy boundaryStrat, Team team, Point2D offsetPos, float mod = 1)
        {
            string       id       = toolObj.Value <string>("id");
            int          mass     = toolObj.Value <int>("mass");
            float        scale    = toolObj.Value <float>("scale");
            int          health   = toolObj.Value <int>("health");
            float        cooldown = toolObj.Value <float>("cooldown") / mod;
            JObject      shapeObj = toolObj.Value <JObject>("shape");
            List <Color> colors   = Util.LoadColors(toolObj.Value <JArray>("colors"));
            Shape        shape    = new ShapeFactory().Create(shapeObj, scale, offsetPos);

            JObject   ammoObj = toolObj.Value <JObject>("ammo");
            Component ammo    = new AmmoFactory().CreateFromReference(ammoObj, entHandler, boundaryStrat, team, offsetPos, mod);

            Tool result = new Tool(id, path, SwinGame.PointAt(0, 0), offsetPos, shape,
                                   colors, health, SwinGame.VectorTo(0, 0), SwinGame.VectorTo(0, -1), cooldown,
                                   boundaryStrat, team, new List <Component>()
            {
                ammo
            }, mass, entHandler);

            entHandler.Track(result);
            return(result);
        }