예제 #1
0
    //private void Awake() {
    //    gm = GameManager.gm;
    //    cm = gm.getCraftManager();
    //    player = gm.getPlayer();
    //}

    // initialize name, ingredients, icon
    public void init(Recipe recipe)
    {
        panel  = GetComponentInParent <CraftPanel>();
        gm     = GameManager.gm;
        cm     = gm.getCraftManager();
        rm     = gm.getResearchManager();
        player = gm.getPlayer();

        this.recipe = recipe;

        name.text         = this.recipe.getProduct().item.getName() + " x " + this.recipe.getProduct().count.ToString();
        ingredients.text  = generateIngredientsText(this.recipe.getIngredients());
        requirements.text = generateRequirementsText(this.recipe);

        icon.sprite = recipe.getProduct().item.getIcon();
    }
예제 #2
0
        public Cow(CowGameScreen cowGameScreen, World world, Vector2 position)
            : base(cowGameScreen, world, new Rectangle((int)position.X, (int)position.Y, 54, 49),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowRightWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowLeftWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowUpWalk"], 3, 16),
                   new DynamicAnimatedSprites(cowGameScreen.GameTextures["cowDownWalk"], 3, 16))
        {
            Inventory  = new Inventory.Inventory(cowGameScreen);
            CraftPanel = new CraftPanel(cowGameScreen);
            ListBars   = new List <StatusBar>
            {
                new HealthBar(cowGameScreen, this),
                new FoodBar(cowGameScreen, this),
                new SprintBar(cowGameScreen, this)
            };
            Delay        = 200f;
            HealthPoint  = 100;
            StarvePoint  = 100;
            CurrentWorld = world;
            Boost        = 1;
            SpeedX       = 1.5f;
            SpeedY       = 1f;
            CurrentWorld = world;

            _interactableList = new List <Entity>();
            _attackList       = new List <Entity>();

            _previousFocusInteractables = new HashSet <Entity>();
            _previousFocusAttackables   = new HashSet <Entity>();

            Body                     = BodyFactory.CreateRectangle(world, 0.54f, 0.15f, 0, new Vector2((float)DestRect.X / 100, (float)DestRect.Y / 100));
            Body.BodyType            = BodyType.Dynamic;
            Body.CollisionCategories = Category.All & ~Category.Cat10;
            Body.CollidesWith        = Category.All & ~Category.Cat10;

            CurrentAnim       = LeftWalk;
            Body.BodyTypeName = "cow";

            CowGameScreen.WordlsList.ForEach(worldInList => worldInList.ContactManager.Nearby += NearbyCow);
        }