• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by alexrweinstein · Feb 04, 2018 at 07:13 PM · errorinheritancedefinition

error CS1061: Type `StoryDeck' does not contain a definition for `populateDeckAndStack' and no extension method `populateDeckAndStack' of type `StoryDeck' could be found

First time programmer here, so apologies if this is trivial. I've gotten this type of error many times before, but this one is really stumping me. AdventureCards are working while StoryCards are not, but they are both set up the same way, even within the same file, since they inherit from a common object.

This following code is where the error is generated:

 using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using UnityEngine;
 using game;

 public class Dealer : MonoBehaviour
 {
     protected AdventureDeck adventureDeck;
     protected StoryDeck storyDeck;
     protected Players players;

     void OnGUI(){
         if (GUI.Button (new Rect (10, 10, 256, 28), "Start Game")) {
             adventureDeck.populateDeckAndStack ();
             storyDeck.populateDeckAndStack (); //ERROR HERE
             for (int i = 0; i < 4; i++) {
                 players.playerStacks.Keys.ElementAt(i).setRank(new RankCard());
             }
             int j=0;
             for (int i = 0; i < 21; i++) {
                 players.Push (adventureDeck.stack.Pop (), j);
                 if(j == 3) 
                     j=0;
                 else j++;
             }
         }
     }
     void Start(){
         adventureDeck = new AdventureDeck();
         storyDeck = new StoryDeck ();
         players = gameObject.AddComponent<Players> () as Players;
     }
 }

And here is the relevant code for the object class being used:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;

 namespace game{
     public abstract class Deck {
         public List<Card> deck; //store all cards in an arraylist called deck
         public CardStack stack;
         public CardStackView view;
         public GameObject go = new GameObject();

         public Deck(){
             deck = new List<Card>();
             stack = go.AddComponent<CardStack> () as CardStack;
             view = go.AddComponent<CardStackView> () as CardStackView;
         }

         ((...lots of functions here (getters, setters, drawCard, etc.)...)

     // nothing here, it will be overrriden in the inherited functions
     public abstract void populateDeckAndStack ();
         
     }

     public class AdventureDeck: Deck
     {
         public override void populateDeckAndStack(){
             //this is where you add each card of each type for adventure cards
             deck.Add (new Ally ("arthur", 10, 2));
             deck.Add (new Ally ("pellinore", 10, 4));
             deck.Add (new Foe ("black knight", 25, 35));
             ((18 more cards))
             for (int i = 0; i < 21; i++) {
                 stack.Push (i);
             }
         }
     }

     public class StoryDeck: Deck
     {
         public override void populateDeckAndStack(){
             deck.Add (new Quest ("boar hunt",2, new Foe ("boar", 5, 15)));
             deck.Add (new Quest ("enchanted forest",3, new Foe ("evil knight", 20, 30)));
             deck.Add (new Quest ("fair maiden",3, new Foe ("black knight", 25, 35)));
             deck.Add (new Quest ("green knight",4, new Foe ("green knight", 25, 40)));
             deck.Add (new Quest ("saxon raiders",2, new List<Foe> { new Foe ("saxons", 10, 20), new Foe ("saxon knight", 15, 25)}));
             deck.Add (new Quest ("slay dragon",4, new Foe ("dragon", 50, 70)));

         }
     }
 } 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

99 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Passing arguments to base constructor fails 1 Answer

An OS design issue: File types associated with their appropriate programs 1 Answer

passing variables through scripts 0 Answers

error CS0101: The namespace `RTS' already contains a definition for `ResourceManager'. What is going on? 1 Answer

Moved assets out of Resources folder: the namespace already contains a definition 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges