コード例 #1
0
 /*
  * This method starts a new build for background objects
  * timeBeforeFinish: The time it takes to build the object (in seconds)
  * element: The object to build
  * */
 public void startBuild(float timeBeforeFinish, BackgroundObject element)
 {
     Console.WriteLine("StartBuild");
     timeBeforeBuildFinish.Add(timeBeforeFinish);
     counterForEachBuild.Add(0.0f);
     elementsToBuild.Add(element);
 }
コード例 #2
0
        public void onMouseHover(BackgroundObject backgroundObject)
        {
            Character player1  = SceneManager.getInstance.getPlayer1();
            bool      doAction = player1.getDoAction();
            string    name     = backgroundObject.Name;

            hoveringOverThisFrame = true;

            if (name != null)
            {
                Vector2 playerPos       = player1.Properties.getProperty <Vector2>("Position");
                Vector2 staticObjectPos = backgroundObject.Properties.getProperty <Vector2>("Position");

                Vector2 newVector = playerPos - staticObjectPos;
                float   distance  = newVector.Length();

                if (distance <= backgroundObject.getInteractionDistance())
                {
                    if (name == "Field" || name == "FieldWithFood") // || name == "FieldFertilised"
                    {
                        backgroundObject.setMouseIsHovering(true);

                        if (name == "Field")
                        {
                            if (SceneManager.getInstance.getPlayer1().hasShovel())
                            {
                                foreach (KeyValuePair <string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures())
                                {
                                    if (texture.Key == "Pickaxe")
                                    {
                                        Properties.updateProperty <Texture2D>("Texture2D", texture.Value);
                                    }
                                }
                            }
                        }
                        else if (name == "FieldWithFood")
                        {
                            foreach (KeyValuePair <string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures())
                            {
                                if (texture.Key == "Mouse")
                                {
                                    Properties.updateProperty <Texture2D>("Texture2D", texture.Value);
                                }
                            }
                        }

                        if (doAction)
                        {
                            backgroundObject.onInteract();
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
コード例 #3
0
 public void onMouseNotHover(BackgroundObject backgroundObject)
 {
     if (backgroundObject.isMouseHovering())
     {
         foreach (KeyValuePair <string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures())
         {
             if (texture.Key == "Mouse")
             {
                 Properties.updateProperty <Texture2D>("Texture2D", texture.Value);
             }
         }
         if (backgroundObject.Properties.getProperty <Color>("Color") != Color.White)
         {
             backgroundObject.Properties.updateProperty <Color>("Color", Color.White);
         }
         backgroundObject.setMouseIsHovering(false);
     }
 }
コード例 #4
0
 public void onMouseNotHover(BackgroundObject backgroundObject)
 {
     if (backgroundObject.isMouseHovering())
     {
         foreach (KeyValuePair<string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures())
         {
             if (texture.Key == "Mouse")
             {
                 Properties.updateProperty<Texture2D>("Texture2D", texture.Value);
             }
         }
         if (backgroundObject.Properties.getProperty<Color>("Color") != Color.White)
         {
             backgroundObject.Properties.updateProperty<Color>("Color", Color.White);
         }
         backgroundObject.setMouseIsHovering(false);
     }
 }
コード例 #5
0
        public void onMouseHover(BackgroundObject backgroundObject)
        {
            Character player1 = SceneManager.getInstance.getPlayer1();
            bool doAction = player1.getDoAction();
            string name = backgroundObject.Name;
            hoveringOverThisFrame = true;

            if (name != null)
            {
                Vector2 playerPos = player1.Properties.getProperty<Vector2>("Position");
                Vector2 staticObjectPos = backgroundObject.Properties.getProperty<Vector2>("Position");

                Vector2 newVector = playerPos - staticObjectPos;
                float distance = newVector.Length();

                if (distance <= backgroundObject.getInteractionDistance())
                {
                    if (name == "Field" || name == "FieldWithFood") // || name == "FieldFertilised"
                    {
                        backgroundObject.setMouseIsHovering(true);

                        if (name == "Field")
                        {
                            if (SceneManager.getInstance.getPlayer1().hasShovel())
                            {
                                foreach (KeyValuePair<string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures())
                                {
                                    if (texture.Key == "Pickaxe")
                                    {
                                        Properties.updateProperty<Texture2D>("Texture2D", texture.Value);
                                    }
                                }
                            }
                        }
                        else if (name == "FieldWithFood")
                        {
                            foreach (KeyValuePair<string, Texture2D> texture in ResourceManager.getInstance.getRuntimeTextures())
                            {
                                if (texture.Key == "Mouse")
                                {
                                    Properties.updateProperty<Texture2D>("Texture2D", texture.Value);
                                }
                            }
                        }

                        if (doAction)
                        {
                            backgroundObject.onInteract();
                        }
                    }
                    else
                    {

                    }
                }
            }
        }
コード例 #6
0
 public BuildBackground(bool active, int index, BackgroundObject backObject)
 {
     this.active     = active;
     this.index      = index;
     this.backObject = backObject;
 }
コード例 #7
0
 public void addElementToBuild(BackgroundObject backObject, int index)
 {
     objectsToBuild.Add(new BuildBackground(true, index, backObject));
 }
コード例 #8
0
 public void addElementToBuild(BackgroundObject backObject, int index)
 {
     objectsToBuild.Add(new BuildBackground(true, index, backObject));
 }
コード例 #9
0
 /*
  * This method starts a new build for background objects
  * timeBeforeFinish: The time it takes to build the object (in seconds)
  * element: The object to build
  * */
 public void startBuild(float timeBeforeFinish, BackgroundObject element)
 {
     Console.WriteLine("StartBuild");
     timeBeforeBuildFinish.Add(timeBeforeFinish);
     counterForEachBuild.Add(0.0f);
     elementsToBuild.Add(element);
 }