Ejemplo n.º 1
0
 public override void Serialize(ICustomDataWriter writer)
 {
     writer.WriteDouble(ContextualId);
     Look.Serialize(writer);
     writer.WriteShort((short)Disposition.ProtocolId);
     Disposition.Serialize(writer);
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        enableText.text = enable ? "<color=red>Disable</color>" : "<color=lime>Enable</color>";

        Move.Enable(enable);
        Look.Enable(enable);
    }
Ejemplo n.º 3
0
            public bool Interact(int x, int y, Interaction interaction)
            {
                if (pixels.Contains(new Point(x, y)))
                {
                    switch (interaction)
                    {
                    case Interaction.Eye:
                        Look?.Invoke();
                        break;

                    case Interaction.Hand:
                        Grab?.Invoke();
                        break;

                    case Interaction.Mouth:
                        Talk?.Invoke();
                        break;

                    default:
                        return(false);
                    }
                }

                return(true);
            }
Ejemplo n.º 4
0
    public static void SendOOTDWinnerEmail(UserProfile user, Look look)
    {
        string apiKey = ConfigurationManager.AppSettings["MandrillAPIKey"];

        var api = new MandrillApi(apiKey);

        var recipients = new List <EmailAddress>();

        recipients.Add(new EmailAddress(user.emailId, user.userName));


        var message = new EmailMessage()
        {
            to         = recipients,
            from_email = "*****@*****.**",
            from_name  = "Cult Collection",
            subject    = "You're today's #OOTD winner!",
        };

        message.AddGlobalVariable("FNAME", user.userName);
        message.AddGlobalVariable("LIMG", "http://startcult.com/images/looks/" + look.id + ".jpg");
        message.AddGlobalVariable("LURL", "http://startcult.com/look.html?lookId=" + look.id + "&userName=Cult_OOTD&url=https://s3-us-west-2.amazonaws.com/fkuserpics/163.jpg&utm_source=email&utm_medium=OOTDemail");
        message.AddGlobalVariable("LDESC", look.title);
        message.important = true;

        var result = api.SendMessageAsync(message, "#OOTD Winner", null);
    }
Ejemplo n.º 5
0
 public override void Serialize(IDataWriter writer)
 {
     writer.WriteDouble(ContextualId);
     Look.Serialize(writer);
     writer.WriteUShort(Disposition.TypeID);
     Disposition.Serialize(writer);
 }
Ejemplo n.º 6
0
 internal void CloneMember(ref Look member, CloneSpriteContext context)
 {
     if (member != null)
     {
         member = context.Looks[member];
     }
 }
Ejemplo n.º 7
0
        private void OnOwnerTurnStart(Fighter obj)
        {
            bool sequence = Fight.SequencesManager.StartSequence(SequenceTypeEnum.SEQUENCE_SPELL);

            Look.AddScale(SCALE_PER_TURN);
            this.ChangeLook(Look, this);

            this.BuffTurnCount--;

            if (ComboDamages == 0)
            {
                ComboDamages = INITIAL_COMBO_DAMAGE;
            }
            else
            {
                ComboDamages *= COMBO_DAMAGE_FACTOR;
            }

            if (BuffTurnCount == 0)
            {
                Owner.OnTurnStartEvt -= OnOwnerTurnStart;
            }
            if (sequence)
            {
                Fight.SequencesManager.EndSequence(SequenceTypeEnum.SEQUENCE_SPELL);
            }
        }
Ejemplo n.º 8
0
        public void Copy(BehaviourModeRuleObject _rule)
        {
            if (_rule == null)
            {
                return;
            }

            base.Copy(_rule);

            Animation.Copy(_rule.Animation);
            Look.Copy(_rule.Look);
            Audio.Copy(_rule.Audio);
            Inventory.Copy(_rule.Inventory);
            Events.Copy(_rule.Events);
            Effect.Copy(_rule.Effect);
            Link.Copy(_rule.Link);
            Move.Copy(_rule.Move);
            Body.Copy(_rule.Body);
            Influences.Copy(_rule.Influences);

            Key                 = _rule.Key;
            LengthMax           = _rule.LengthMax;
            LengthMin           = _rule.LengthMin;
            LengthMaximum       = _rule.LengthMaximum;
            Weight              = _rule.Weight;
            UseCustomLength     = _rule.UseCustomLength;
            FoldoutCustomLength = _rule.FoldoutCustomLength;
        }
    private void Find(StateController p_controller)
    {
        Transform        transform = p_controller.m_entity.transform;
        EntityRuntimeSet enemies   = p_controller.m_enemyEntities;
        Look             look      = p_controller.m_look;

        if (!enemies)
        {
            return;
        }

        foreach (Entity enemy in enemies.m_items)
        {
            Transform enemyTransform = enemy.transform;
            float     distance       = Vector2.Distance(transform.position, enemyTransform.position);

            if (distance <= p_controller.m_look.m_lookRange)
            {
                Vector2 direction = enemyTransform.position - transform.position;
                float   angle     = Vector2.Angle(direction, transform.right);

                if (look.m_fieldOfView / 2 >= angle || distance <= look.m_lookSphereRadius)
                {
                    RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, distance + 1);

                    if (hit.collider && hit.collider.gameObject == enemy.gameObject)
                    {
                        p_controller.m_target = enemy;
                        return;
                    }
                }
            }
        }
    }
Ejemplo n.º 10
0
 public void Setup()
 {
     m_entity       = GetComponent <Entity>();
     m_shotPatterns = new Dictionary <ShootAction, List <ShotPattern> >();
     m_look         = m_entity.m_look;
     m_entity.m_ai  = this;
 }
Ejemplo n.º 11
0
    public void SendNotifications(long lookId, long userId, string appAccessToken, VoteType vote)
    {
        string db = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;

        //bool isVoted = false;
        Look look = Look.GetLookById(lookId, userId, db);

        //send notification to the creator of the outfit unless the creator is a bot (bot is <=0)
        if (look.creator.facebookId > 0 && vote == VoteType.UpVote)
        {
            UserProfile user = UserProfile.GetUserProfileById(userId, db);

            //Post a fb notification that user has loved a vote

            try
            {
                if (UserProfile.IsFriend(look.creator.userId, user.facebookId))
                {
                    //Send the notification only if the user is creator's friend
                    appAccessToken = FacebookHelper.SendNotification(appAccessToken, look.creator.facebookId, user.facebookId, look);
                    this.Session["app_access_token"] = appAccessToken;
                }
            }
            catch (Facebook.FacebookOAuthException ex)
            {
                //Log the oauth exception.
            }
        }

        //send notification to a voter if their friend voted on the same outfit
    }
        public Element Get(ResolveInfoComponent resolveInfo, ActionSet actionSet, Element target)
        {
            ActionSet       = actionSet;
            ResolveInfo     = resolveInfo;
            Target          = target;
            PathmapInstance = actionSet.DeltinScript.GetComponent <PathfinderTypesComponent>().Pathmap;

            // Lookahead status
            IndexReference result = actionSet.VarCollection.Assign("Lookahead: Result", actionSet.IsGlobal, true);

            actionSet.AddAction(result.SetVariable(Element.False()));

            // The lookhead controller
            Look = actionSet.VarCollection.Assign("Pathfind: Lookahead", actionSet.IsGlobal, true);
            actionSet.AddAction(Look.SetVariable(resolveInfo.Current.Get(target)));

            // The loop
            actionSet.AddAction(Element.While(Element.And(
                                                  !result.Get(),
                                                  LoopCondition()
                                                  )));

            // Set the result.
            actionSet.AddAction(result.SetVariable(SetResult()));

            // End
            actionSet.AddAction(Look.SetVariable(Next));
            actionSet.AddAction(Element.End());
            return(result.Get());
        }
Ejemplo n.º 13
0
        public override void UpdateViewMatrix()
        {
            if (Beta < MinBeta)
            {
                Beta = MinBeta;
            }

            var sideRadius = Radius * Beta.Cos();
            var height     = Radius * Beta.Sin();

            if (Target.Y + height < MinY)
            {
                height = MinY - Target.Y;
            }

            Position = new Vector3(
                Target.X + sideRadius * Alpha.Cos(),
                Target.Y + height,
                Target.Z + sideRadius * Alpha.Sin());
            SetView(Matrix.LookAtRH(Position, Target, GetUpTilt(Target, Vector3.UnitY)));

            Right = new Vector3(View.M11, View.M21, View.M31);
            Right.Normalize();

            Up = new Vector3(View.M12, View.M22, View.M32);
            Up.Normalize();

            Look = -new Vector3(View.M13, View.M23, View.M33);
            Look.Normalize();
        }
Ejemplo n.º 14
0
    // Use this for initialization
    void Start () {
	    ps = GetComponent<PlayerState>();
        look = cockpit.gameObject.GetComponent<Look>();
        legs = new List<Leg>(GetComponents<Leg>());

        
    }
Ejemplo n.º 15
0
 public void Dispose()
 {
     if (Map != null)
     {
         Map.Instance.RemoveClient(Client);
     }
     if (SearchingArena)
     {
         ArenaProvider.Instance.OnClientDisconnected(Client);
     }
     if (IsFighting)
     {
         FighterInstance.OnDisconnect();
     }
     if (PlayerTradeInstance != null)
     {
         PlayerTradeInstance.Abort();
     }
     if (PartyMember != null)
     {
         PartyMember.Party.QuitParty(Client);
     }
     if (DungeonPartyProvider.Instance.GetDPCByCharacterId(this.Id) != null)
     {
         DungeonPartyProvider.Instance.RemoveCharacter(this);
     }
     Client.Character.Look.UnsetAura();
     Record.Look = Look.ConvertToString();
     SaveTask.UpdateElement(Record);
     SaveTask.UpdateElement(StatsRecord);
     Inventory.InitializeForSaveTask();
 }
Ejemplo n.º 16
0
        public Element Get(ResolveInfoComponent resolveInfo, ActionSet actionSet, Element target)
        {
            ActionSet       = actionSet;
            ResolveInfo     = resolveInfo;
            Target          = target;
            PathmapInstance = actionSet.Translate.DeltinScript.Types.GetInstance <PathmapClass>();

            // Lookahead status
            IndexReference result = actionSet.VarCollection.Assign("Lookahead: Result", actionSet.IsGlobal, true);

            actionSet.AddAction(result.SetVariable(new V_False()));

            // The lookhead controller
            Look = actionSet.VarCollection.Assign("Pathfind: Lookahead", actionSet.IsGlobal, true);
            actionSet.AddAction(Look.SetVariable(resolveInfo.Current.Get(target)));

            // The loop
            actionSet.AddAction(Element.Part <A_While>(Element.Part <V_And>(
                                                           !result.Get(),
                                                           LoopCondition()
                                                           )));

            // Set the result.
            actionSet.AddAction(result.SetVariable(SetResult()));

            // End
            actionSet.AddAction(Look.SetVariable(Next));
            actionSet.AddAction(new A_End());
            return(result.Get());
        }
Ejemplo n.º 17
0
        public new static Namespace Match()
        {
            var space = new Namespace();

            Match(NAMESPACE);
            space.name = Look.ToString();
            Match(ID);
            if (Check('-'))
            {
                Match('-');
                Match('>');
                space.classes.Add(Class.Match(space));
            }
            else
            {
                Match('{');
                while (Check(OBJ))
                {
                    space.classes.Add(Class.Match(space));
                }
                Match('}');
            }
            name_spaces.Add(space);
            return(space);
        }
Ejemplo n.º 18
0
 public GameRolePlayCharacterInformations GetRolePlayActorInformations()
 {
     return(new GameRolePlayCharacterInformations(Id, Look.ToEntityLook(),
                                                  new EntityDispositionInformations(Record.CellId, Record.Direction),
                                                  Record.Name, new HumanInformations(Restrictions, Record.Sex, HumanOptions),
                                                  Client.Account.Id, GetActorAlignement()));
 }
Ejemplo n.º 19
0
    public void SendNotifications(Look look, string appAccessToken)
    {
        string db = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;

        //send notification to the creator of the outfit unless the creator is a bot (bot is <=0)
        if (look.creator.facebookId > 0)
        {
            //Get look's creator's follower's facebook ids
            List <long> followerIds = UserProfile.GetUserFollowersFacebookIds(look.creator.userId, db);

            //Post a fb notification to user's followers that user has posted a look
            foreach (long followerId in followerIds)
            {
                try
                {
                    appAccessToken = FacebookHelper.SendCreateNotification(appAccessToken, look.creator.facebookId, followerId, look);
                    this.Session["app_access_token"] = appAccessToken;
                }
                catch (Facebook.FacebookOAuthException ex)
                {
                    //Log the oauth exception.
                }
            }
        }

        //send notification to a voter if their friend voted on the same outfit
    }
Ejemplo n.º 20
0
        public static void teleportch(CharacterInstance ch, RoomTemplate room, bool show)
        {
            if (room.IsPrivate())
            {
                return;
            }

            comm.act(ATTypes.AT_ACTION, "$n disappears suddenly!", ch, null, null, ToTypes.Room);
            ch.CurrentRoom.RemoveFrom(ch);
            room.AddTo(ch);
            comm.act(ATTypes.AT_ACTION, "$n arrives suddenly!", ch, null, null, ToTypes.Room);

            if (show)
            {
                Look.do_look(ch, "auto");
            }

            if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Death) &&
                !ch.IsImmortal())
            {
                comm.act(ATTypes.AT_DEAD, "$n falls prey to a terrible death!", ch, null, null, ToTypes.Room);
                ch.SetColor(ATTypes.AT_DEAD);
                ch.SendTo("Oopsie... you're dead!");

                var buffer = $"{ch.Name} hit a DEATH TRAP in room {ch.CurrentRoom.ID}!";
                ChatManager.to_channel(buffer, ChannelTypes.Monitor, "Monitor", (short)LevelConstants.ImmortalLevel);
                ch.Extract(false);
            }
        }
Ejemplo n.º 21
0
        public AdventureCommandRegistry(IReadonlyAdventureGame game)
        {
            var lookCommand      = new Look(game, "look", "l");
            var helpCommand      = new Help(game, "help");
            var moveCommand      = new Move(game, "move", "go", "walk", "run", "climb", "crawl");
            var takeCommand      = new Take(game, "take", "get", "grab");
            var dropCommand      = new Drop(game, "drop");
            var magicWord1       = new Xyzzy(game, "xyzzy");
            var magicWord2       = new Plugh(game, "plugh");
            var inventoryCommand = new Carrying(game, "inventory", "inv");
            var interactCommand  = new Interact(game, "use"); // Do not add aliases for this command
            var yes = new Yes(game, "yes", "y");
            var no  = new No(game, "no", "n");
            var say = new Say(game, "say");

            RegisteredCommands = new List <IAdventureCommand> {
                lookCommand,
                helpCommand,
                moveCommand,
                takeCommand,
                dropCommand,
                magicWord1,
                magicWord2,
                inventoryCommand,
                interactCommand,
                yes,
                no,
                say,
            };
        }
Ejemplo n.º 22
0
    private LookMessage SaveLook()
    {
        string db    = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;
        string query = "EXEC [stp_SS_SaveLook] @product='" + productMap + "', @uid=" + this.userId + ",@tag='" + tagMap + "', @title=N'" + this.title + "',@color ='" + this.colormap + "'";

        if (originalLookId != 0)
        {
            query += (", @originalLook=" + this.originalLookId);
        }

        SqlConnection myConnection = new SqlConnection(db);

        LookMessage msg = new LookMessage();

        try
        {
            myConnection.Open();
            using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection))
            {
                SqlCommand cmd = adp.SelectCommand;
                cmd.CommandTimeout = 300000;
                System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
                Look look = new Look();

                look = Look.GetLookFromSqlReader(dr);

                msg.Look            = look;
                msg.LookDescription = look.title;

                foreach (Tag tag in msg.Look.tags)
                {
                    if (!tag.name.StartsWith("#"))
                    {
                        msg.LookDescription += ("#" + tag.name);
                    }
                    else
                    {
                        msg.LookDescription += tag.name;
                    }

                    msg.LookDescription += " ";
                }

                for (int i = 0; i < msg.Look.products.Count; i++)
                {
                    msg.LookDescription += "#" + (msg.Look.products[i].brandName);
                    if (i < msg.Look.products.Count - 1)
                    {
                        msg.LookDescription += " ";
                    }
                }
            }
        }
        finally
        {
            myConnection.Close();
        }

        return(msg);
    }
Ejemplo n.º 23
0
    private void OnTriggerEnter(Collider collision)
    {
        bool is_player = false;

        if (collision.gameObject.tag.Equals("Player") || collision.gameObject.layer == 2)
        {
            is_player = true;
        }

        Look    look    = collision.gameObject.GetComponent <Look>();
        Element element = collision.gameObject.GetComponent <Element>();

        if (look != null)
        {
            look     = collision.gameObject.GetComponent <Look>();
            look.Hp -= 1;
        }
        if (element != null)
        {
        }

        if (!is_player)
        {
            Destroy(gameObject);
        }
        else
        {
        }
    }
Ejemplo n.º 24
0
 public override GameFightFighterInformations GetFightFighterInformations()
 {
     return(new GameFightCharacterInformations(Id, Look.ToEntityLook(), new EntityDispositionInformations((short)CellId,
                                                                                                          (sbyte)Direction), Team.Id, 0, Alive, Stats.GetFightMinimalStats(), new ushort[0], Character.Name, Character.GetPlayerStatus(),
                                               (byte)Character.Level, Character.Record.Alignment.GetActorAlignmentInformations(),
                                               Character.Record.BreedId, Character.Record.Sex));
 }
Ejemplo n.º 25
0
 public override GameRolePlayActorInformations GetActorInformations()
 {
     return(new GameRolePlayGroupMonsterInformations((int)Id, Look.ToEntityLook(),
                                                     new EntityDispositionInformations((short)CellId, (sbyte)Direction), false,
                                                     false, false, GetGroupMonsterStaticInformations(),
                                                     this.CreationDate.DateTimeToUnixTimestamp(), 0, 0, 0));
 }
        public override void Serialize(ICustomDataWriter writer)
        {
            base.Serialize(writer);

            Look.Serialize(writer);
            writer.WriteByte((byte)Breed);
        }
Ejemplo n.º 27
0
        public static List <Look> SendEmailToFeaturedLookCreator(List <long> lookIds, string tagName)
        {
            var         api   = new MandrillApi(apiKey);
            List <Look> looks = new List <Look>();

            //Send look owenrs congrats email
            if (lookIds.Count > 0)
            {
                //get look details and fill it in
                for (int l = 1; l <= lookIds.Count; l++)
                {
                    Look look = Look.GetLookById(lookIds[l - 1], 0, db);
                    looks.Add(look);
                    var recipients = new List <EmailAddress>();
                    recipients.Add(new EmailAddress(look.creator.emailId, look.creator.userName));
                    var message = new EmailMessage()
                    {
                        to         = recipients,
                        from_email = "*****@*****.**",
                        from_name  = "Cult Collection",
                        subject    = "Your Look Was Featured",
                    };

                    if (look.id > 0)
                    {
                        message.AddGlobalVariable("L1URL", "http://startcult.com/look.html?lookId=" + look.id + "&userName=CultCollection&url=http://startcult.com/images/100x100_identity_.png&utm_source=email&utm_medium=WeeklyDigest&utm_term=consumption");
                        message.AddGlobalVariable("L1IMG", "http://startcult.com/images/looks/" + look.id + ".jpg");
                        message.AddGlobalVariable("U1", look.creator.userName);
                        message.AddGlobalVariable("S1", (look.upVote + look.restyleCount).ToString());
                        message.AddGlobalVariable("L1DESC", look.title);
                    }
                    message.important = true;
                    var result = api.SendMessage(message, "Your Look was Featured", null);

                    //Make it featured
                    if (!string.IsNullOrEmpty(tagName))
                    {
                        string        query        = "EXEC [stp_SS_UpdateLookTagMap] @tName=N'" + tagName + "', @lId=" + lookIds[l - 1] + ", @type=1,@featured=1";
                        SqlConnection myConnection = new SqlConnection(db);

                        try
                        {
                            myConnection.Open();
                            using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection))
                            {
                                SqlCommand cmd = adp.SelectCommand;
                                cmd.CommandTimeout = 300000;
                                cmd.ExecuteNonQuery();
                            }
                        }
                        finally
                        {
                            myConnection.Close();
                        }
                    }
                }
            }
            return(looks);
        }
Ejemplo n.º 28
0
 public TaxCollectorInformations GetNetworkTaxCollector()
 {
     return(new TaxCollectorInformations(GlobalId, FirstNameId, LastNameId,
                                         GetAdditionalTaxCollectorInformations(),
                                         (short)Position.Map.Position.X, (short)Position.Map.Position.Y,
                                         (short)Position.Map.SubArea.Id, (sbyte)GetState(),
                                         Look.GetEntityLook(), GetTaxCollectorComplementaryInformations()));
 }
Ejemplo n.º 29
0
 public void MakeOrthogonal()
 {
     Look.Normalize();
     Up    = Vector3.Cross(Look, Right);
     Right = Vector3.Cross(Up, Look);
     Up.Normalize();
     Right.Normalize();
 }
Ejemplo n.º 30
0
        public static Character StandardEnemy(Stats stats, Look look, Brain brain)
        {
            Character enemy = new Character(stats, look, brain);

            enemy.AddFlag(Model.Characters.Flag.DROPS_ITEMS);
            enemy.AddFlag(Model.Characters.Flag.GIVES_EXPERIENCE);
            return(enemy);
        }
        public ActionResult Details(int id)
        {
            IQueryable <Look> u = db.Looks.Include(p => p.Photos);
            Look look           = u.Where(l => l.Id == id).First();

            ViewBag.Photos = look.Photos;
            ViewBag.UserId = look.UserId;
            return(View(look));
        }
Ejemplo n.º 32
0
        public static async Task ReplaceImageInStorage(Program project, Look look, PortableImage newImage)
        {
            var path = Path.Combine(project.BasePath, StorageConstants.ProgramLooksPath, look.FileName);

            using (var storage = StorageSystem.GetStorage())
            {
                await storage.SaveImageAsync(path, newImage, true, ImageFormat.Png);
                look.Image = await storage.LoadImageThumbnailAsync(path);
            }
        }
 private void InitCurrentProject()
 {
     var catLook = new Look {Name = "Cat"};
     CurrentProject = new Program
     {
         Name = "Project 1 with very very very very very long name",
         Description = "Dies ist eine Test Anwendung.",
         UploadHeader = new UploadHeader
         {
             MediaLicense = "http://developer.catrobat.org/ccbysa_v3",
             ProgramLicense = "http://developer.catrobat.org/agpl_v3",
             RemixOf = "",
             Tags = new ObservableCollection<string>(),
             Url = "http://pocketcode.org/details/871",
             UserId = "Username"
         },
         Sprites = new ObservableCollection<Sprite>
         {
             new Sprite
             {
                 Name = "Object 1",
                 Looks = new ObservableCollection<Look> {catLook},
                 Sounds = new ObservableCollection<Sound> {new Sound {Name = "Miau Sound"}},
                 LocalVariables = new ObservableCollection<LocalVariable>
                 {
                     new LocalVariable {Name = "LocalVariable 1"},
                     new LocalVariable {Name = "LocalVariable 2"}
                 },
                 Scripts = new ObservableCollection<Script>
                 {
                     new StartScript
                     {
                         Bricks = new ObservableCollection<Brick>
                         {
                             new SetLookBrick
                             {
                                 Value = catLook,
                             }
                         }
                     }
                 }
             }
         },
         GlobalVariables = new ObservableCollection<GlobalVariable>
         {
             new GlobalVariable {Name = "GlobalVariable 1"},
             new GlobalVariable {Name = "GlobalVariable 2"}
         }
     };
 }
Ejemplo n.º 34
0
 public Player(string name, Minecraft minecraft)
 {
     this.name = name;
     this.minecraft = minecraft;
     entityID = 0;
     this.position = new XYZ<double> (0, 0, 0);
     look = new Look<float> (0, 0);
     moving = new Timer (50);
     moving.Elapsed += delegate( object source, ElapsedEventArgs e ) {
         this.nextMove ();
     };
     moving.Start ();
     speed = 5;//per 1 second
     //endPosition = new XYZ<double> (0, 0, 0);
 }
Ejemplo n.º 35
0
        public void TestDrawLine()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new LineShape (0.0, 0.0, 32.0, 32.0);
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/line.png");
            image.Dispose ();
        }
Ejemplo n.º 36
0
 public static void CleanUpLookReferences(Look deletedLook, Sprite selectedSprite)
 {
     foreach (var script in selectedSprite.Scripts)
     {
         foreach (var brick in script.Bricks)
         {
             if (brick is SetLookBrick)
             {
                 var setLookBrick = brick as SetLookBrick;
                 if (ReferenceEquals(setLookBrick.Value, deletedLook))
                     setLookBrick.Value = null;
             }
         }
     }
 }
Ejemplo n.º 37
0
        public void TestBranchIteration()
        {
            var a = new EllipseShape ();
            var b = new RectangleShape ();
            var c = new LineShape (0.0, 0.0, 32.0, 32.0);
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, a);
            op.AddChild (look, b).AddChild (look, c);

            // Iterate through each member of the branch.
            var list = new List<ShapeBase> ();
            foreach (var item in op) {
                list.Add (item);
            }

            Assert.True (list[0] == b);
            Assert.True (list[1] == c);
        }
Ejemplo n.º 38
0
        public static async Task<Look> Save(PortableImage image, string name, ImageDimension dimension, string projectPath)
        {
            using (var storage = StorageSystem.GetStorage())
            {
                var imagePath = Path.Combine(projectPath, StorageConstants.ProgramLooksPath);
                if (!await storage.DirectoryExistsAsync(imagePath))
                    await storage.CreateDirectoryAsync(imagePath);
            }

            var resizedImage = await ServiceLocator.ImageResizeService.ResizeImage(image, dimension.Width, dimension.Height);
            var look = new Look(name);
            var absoluteFileName = Path.Combine(projectPath, StorageConstants.ProgramLooksPath, look.FileName);

            await resizedImage.WriteAsPng(absoluteFileName);

            //look.Image = resizedImage;

            return look;
        }
Ejemplo n.º 39
0
        public void TestDrawEllipse()
        {
            var bytes = new byte[1024 * 4];
            var format = Cairo.Format.ARGB32;
            var image = new Cairo.ImageSurface (bytes, format, 32, 32, 32 * 4);
            var shape = new EllipseShape ();
            shape.Rectangle = new Rectangle () {
                X = 10.0,
                Y = 4.0,
                Width = 12.0,
                Height = 18.0
            };
            var look = new Look (SolidBrush.Red, SolidPen.Black);
            var op = new ShapeTree (look, shape);
            using (var context = new Cairo.Context (image)) {
                op.Draw (context);
            }

            image.WriteToPng ("testimages/ellipse.png");
            image.Dispose ();
        }
        public async Task DrawPictureAsync(Core.Models.Program program = null, Look lookToEdit = null)
        {
            _program = program;
            _lookToEdit = lookToEdit;

            //TODO refactor this --> use Storage-service
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            string paintTempFolderPath = Path.GetDirectoryName(StorageConstants.TempPaintImagePath);
            string paintTempFileName = Path.GetFileName(StorageConstants.TempPaintImagePath);
            StorageFolder paintTempFolder = await localFolder.CreateFolderAsync(paintTempFolderPath, CreationCollisionOption.OpenIfExists);

            if (program != null && lookToEdit != null)
            {
                using (var storage = StorageSystem.GetStorage())
                {
                    await storage.DeleteFileAsync(StorageConstants.TempPaintImagePath);
                    string filePath = Path.Combine(program.BasePath,
                        StorageConstants.ProgramLooksPath, lookToEdit.FileName);

                    if(await storage.FileExistsAsync(filePath))
                    {
                        await storage.CopyFileAsync(filePath, StorageConstants.TempPaintImagePath);
                    }
                    else
                    {
                        //ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Import_FileNotFound,
                        //AppResourcesHelper.Get("Import_FileNotFoundText, null, MessageBoxOptions.Ok);
                        await CreateDefaultImage();
                    }
                }
            }
            else
            {
                await CreateDefaultImage();
            }
            var file = await paintTempFolder.GetFileAsync(paintTempFileName);

            var options = new Windows.System.LauncherOptions
            {
                DisplayApplicationPicker = false
            };

            try
            {
                bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
                if (success)
                {
                    // File launch OK
                }
                else
                {
                    // File launch failed
                }
            }
            catch (Exception)
            {
                if (Debugger.IsAttached)
                    Debugger.Break();
            }
        }
        public async void RecievedFiles(IEnumerable<object> files)
        {
            var fileArray = files as object[] ?? files.ToArray();

            if (fileArray.Length == 0)
            {
                ServiceLocator.DispatcherService.RunOnMainThread(() =>
                    ServiceLocator.NavigationService.NavigateTo<NewLookSourceSelectionViewModel>());
            }
            StorageFile file = (StorageFile)fileArray[0];

            var fileStream = await file.OpenReadAsync();
            var memoryStream = new MemoryStream();
            fileStream.AsStreamForRead().CopyTo(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);

            BitmapImage imagetobind = new BitmapImage();
            await imagetobind.SetSourceAsync(memoryStream.AsRandomAccessStream());

            WriteableBitmap writeableBitmap = new WriteableBitmap(imagetobind.PixelWidth, imagetobind.PixelHeight);
            await writeableBitmap.FromStream(memoryStream.AsRandomAccessStream());
            memoryStream.Seek(0, SeekOrigin.Begin);
            PortableImage portableImage = new PortableImage(writeableBitmap)
            {
                Width = writeableBitmap.PixelWidth,
                Height = writeableBitmap.PixelHeight,
                EncodedData = memoryStream
            };

            if (_lookToEdit == null)
            {
                if (portableImage != null) // TODO: check if image is ok
                {
                    var message = new GenericMessage<PortableImage>(portableImage);
                    Messenger.Default.Send(message, ViewModelMessagingToken.LookImageListener);

                    ServiceLocator.DispatcherService.RunOnMainThread(() =>
                        ServiceLocator.NavigationService.NavigateTo<LookNameChooserViewModel>());
                }
                else
                {
                    ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Editor_MessageBoxWrongImageFormatHeader"),
                        AppResourcesHelper.Get("Editor_MessageBoxWrongImageFormatText"), delegate { /* no action */ }, MessageBoxOptions.Ok);
                }
            }
            else
            {
                using (var storage = StorageSystem.GetStorage())
                {
                    var filePath = Path.Combine(_program.BasePath,
                        StorageConstants.ProgramLooksPath, _lookToEdit.FileName);

                    await storage.DeleteImageAsync(filePath);

                    var lookFileStream = await storage.OpenFileAsync(filePath,
                        StorageFileMode.Create, StorageFileAccess.Write);

                    await (await file.OpenReadAsync()).AsStream().CopyToAsync(lookFileStream);

                    lookFileStream.Dispose();

                    await storage.TryCreateThumbnailAsync(filePath);

                    _lookToEdit.Image = await storage.LoadImageThumbnailAsync(filePath);
                }

                _lookToEdit = null;
            }
        }
        private void EditLookAction(Look look)
        {
            var message = new GenericMessage<Look>(look);
            Messenger.Default.Send(message, ViewModelMessagingToken.LookListener);

            ServiceLocator.NavigationService.NavigateTo<ChangeLookViewModel>();
        }
Ejemplo n.º 43
0
        public void Update(GameTime gameTime, Vector2 PlayerPosition)
        {
            face = Vector2.Normalize(PlayerPosition - position);

            if (Direction == Vector2.Zero) // if enemy is not moving
            {
                if (face.Y < 0) // if player is above the enemy
                    animator.ChangeAnimation(8, 8, 1, fps);
                if (face.Y > 0) // if player is below the enemy
                    animator.ChangeAnimation(2, 2, 1, fps);
                if (face.X > 0.8f) // if player on the right side of the enemy
                    animator.ChangeAnimation(13, 13, 1, fps);
                if (face.X < -0.8f) // if player on the left side of the enemy
                    animator.ChangeAnimation(19, 19, 1, fps);
                look = Look.None;
            }
            else if (Direction.X > 0.8f) // if player on the right side of the enemy
            {
                if (look != Look.Right)
                animator.ChangeAnimation(13, 16, 6, fps);
                look = Look.Right;
            }
            else if (Direction.X < -0.8f) // if player on the left side of the enemy
            {
                if (look != Look.Left)
                animator.ChangeAnimation(19, 20, 6, fps);
                look = Look.Left;
            }
            else if (Direction.Y > 0) // if player below the enemy
            {
                if (look != Look.Down)
                animator.ChangeAnimation(1, 1, 4, fps);
                look = Look.Down;
            }
            else if (Direction.Y < 0) // if player above the enemy
            {
                if (look != Look.Up)
                animator.ChangeAnimation(7, 7, 4, fps);
                look = Look.Up;
            }

            if ((PlayerPosition - position).Length() < 500)
            {
                Direction = Vector2.Normalize(PlayerPosition - position);
            }
            else
            {
                Direction = Vector2.Zero;
            }

            animator.Update(gameTime);

            position += Direction * speed;
        }
Ejemplo n.º 44
0
 public OtherPlayer()
 {
     position = new XYZ<int> (0, 0, 0);
     look = new Look<byte> (0, 0);
     armor = new Dictionary<int, Armor> ();
 }
Ejemplo n.º 45
0
 public Mob()
 {
     position = new XYZ<int> (0, 0, 0);
     look = new Look<byte> (0,0);
 }