Mercurial > fife-parpg
comparison demos/rpg/scripts/actors/baseactor.py @ 520:b6bd314df28a
Added a quest dialog.
Added QuestGiver class.
Moved level specific settings to another file.
Added BaseItem class.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 27 May 2010 16:29:07 +0000 |
parents | 14f777be6b94 |
children | 494c60cf61cf |
comparison
equal
deleted
inserted
replaced
519:14f777be6b94 | 520:b6bd314df28a |
---|---|
27 import sys, os, re, math, random, shutil | 27 import sys, os, re, math, random, shutil |
28 | 28 |
29 from fife import fife | 29 from fife import fife |
30 from fife.extensions.loaders import loadMapFile | 30 from fife.extensions.loaders import loadMapFile |
31 | 31 |
32 from scripts.objects.baseobject import ObjectActionListener, BaseGameObject | 32 from scripts.objects.baseobject import ObjectActionListener, BaseGameObject, GameObjectTypes |
33 | 33 |
34 Actions = {'NONE':0, | 34 Actions = {'NONE':0, |
35 'PICKUP':1, | 35 'PICKUP':1, |
36 'TALK':2, | 36 'TALK':2, |
37 'HIT':3} | 37 'HIT':3, |
38 'OPEN':4, | |
39 'ENTER':5} | |
38 | 40 |
39 class BaseAction(object): | 41 class BaseAction(object): |
40 def __init__(self): | 42 def __init__(self): |
41 self._actiontype = Actions['NONE'] | 43 self._actiontype = Actions['NONE'] |
42 | 44 |
48 self._actiontype = Actions['TALK'] | 50 self._actiontype = Actions['TALK'] |
49 self._source = sourceobj | 51 self._source = sourceobj |
50 self._dest = destobj | 52 self._dest = destobj |
51 | 53 |
52 def execute(self): | 54 def execute(self): |
53 print "talking" | 55 print "talking to: " + self._dest.instance.getId() |
56 self._source.showQuestDialog() | |
54 | 57 |
55 ActorStates = {'STAND':0, | 58 ActorStates = {'STAND':0, |
56 'WALK':1, | 59 'WALK':1, |
57 'ATTACK':2} | 60 'ATTACK':2} |
58 | 61 |
74 self._actionlistener = ActorActionListener(self._gamecontroller, self) | 77 self._actionlistener = ActorActionListener(self._gamecontroller, self) |
75 | 78 |
76 self._nextaction = None | 79 self._nextaction = None |
77 | 80 |
78 self.stand() | 81 self.stand() |
82 | |
83 self._type = GameObjectTypes["NPC"] | |
79 | 84 |
80 def stand(self): | 85 def stand(self): |
81 self._state = ActorStates["STAND"] | 86 self._state = ActorStates["STAND"] |
82 self._instance.act('stand', self._instance.getFacingLocation()) | 87 self._instance.act('stand', self._instance.getFacingLocation()) |
83 | 88 |
102 def _setNextAction(self, action): | 107 def _setNextAction(self, action): |
103 self._nextaction = action | 108 self._nextaction = action |
104 | 109 |
105 state = property(_getState, _setState) | 110 state = property(_getState, _setState) |
106 nextaction = property(_getNextAction, _setNextAction) | 111 nextaction = property(_getNextAction, _setNextAction) |
112 | |
113 class QuestGiver(Actor): | |
114 def __init__(self, gamecontroller, instancename, instanceid=None, createInstance=False): | |
115 super(QuestGiver, self).__init__(gamecontroller, instancename, instanceid, createInstance) | |
116 | |
117 self._type = GameObjectTypes["QUESTGIVER"] | |
118 self._quests = [] | |
119 | |
120 def addQuest(self, quest): | |
121 self._quests.append(quest) |