//spieler array
spieler = ["rot","blau","gruen","gelb"]
Array.prototype.changePlayer = function () {
_root.player = this.shift ()
this.push (_root.player)
trace (_root.player)
}
spieler.changePlayer ()
figur = function (startpos,maximal,id) {
//startpos = die nummer des Feldes
this.startpos = startpos;
//anzahl der Felder
this.maximal = maximal+startpos;
//damit man weiß ob die Figur im Feld ist
this.onfield = false;
//id damit man unterscheiden kann ob es sich um eine eigene Figur handelt oder ein gegner ist
this.id = id;
}
figur.prototype = new MovieClip ();
figur.prototype.getFirstPos = function () {
//anfangswerte damit man eine Figur zurücksetzten kann
this.altx = this._x
this.alty = this._y
}
figur.prototype.setBackToStart = function () {
trace ("hallo")
trace (this._name)
trace (this.altx)
//falls man eine Figur rausschmeißt das sie wieder an den
//anfang kommt
this._x = this.altx
this._y = this.alty
this.onfield = false
}
figur.prototype.setToField = function () {
this.getFirstPos ()
//auf das erste angegebene Feld setzen
this._x = _root["mc"+this.startpos]._x
this._y = _root["mc"+this.startpos]._y
//sagen das die Figur auf dem Feld ist
this.onfield = true
//addition aller gefahrenen felder = 0
this.moved = this.startpos
this.zahl = 0
this.pos = this.startpos
this.checkEndField ()
}
figur.prototype.checkEndField = function () {
//falls ein Feld schon besetzt ist
//setze zurück auf den start
trace ("checkEndField")
trace (_root["mc"+this.moved].spieler)
if (_root["mc"+this.moved%40].spieler != undefined) {
trace ("spieler gefunden")
_root[_root["mc"+this.moved%40].spieler].setBackToStart ()
}
_root["mc"+this.pos%40].spieler = undefined
_root["mc"+this.pos%40].id = ""
this.pos += this.zahl;
_root["mc"+this.moved%40].spieler = this._name
_root["mc"+this.moved%40].id = this.id
endPlayer ()
}
figur.prototype.setBackToLatestPos = function () {
//falls zurück gesetzt werden muss durch regelvestoß
this._x = _root["mc"+this.pos%40]._x
this._y = _root["mc"+this.pos%40]._y
this.moved = this.pos
delete this.onEnterFrame;
}
figur.prototype.doNextStep = function () {
trace ("doNextStep")
if (this.moved < this.zahl+this.pos) {
this.moved++
this._x = _root["mc"+this.moved%40]._x
this._y = _root["mc"+this.moved%40]._y
}
this.checkEveryField ()
if (this.moved == this.zahl+this.pos) {
delete this.onEnterFrame;
this.checkEndField ()
}
}
figur.prototype.checkEveryField = function () {
trace ("checkEveryField")
//wenn 2 gleiche ids auf einem Feld sind dann sage das der zug nicht möglich ist
//man kann seinen eigenen mann nicht überspringen
if (_root["mc"+this.moved%40].id == this.id) {
this.setBackToLatestPos()
}
}
figur.prototype.move = function () {
if (this.id == _root.player) {
trace (this.zahl)
if (this.onfield == true) {
this.pos = this.moved
this.onEnterFrame = function () { this.doNextStep() }
}
if (this.onfield == false) {
if (this.zahl == 6) {
this.setToField()
}
}
}
}
figur.prototype.onRelease = function () {
this.zahl = _root.zahl
this.move ()
}
endPlayer = function () {
trace ("endplayer")
if (_root.zahl != 6) {
spieler.changePlayer ()
trace (_root.player)
_root.zahl = 0
//spielerwechsel
}
else {
_root.zahl = 0
//nochmal
}
}
wurf.onRelease = function () {
_root.zahl = random (6)+1
trace (_root.zahl)
output.text = "Console:\n"+_root.zahl+"\n"+_root.player
}
blau1.__proto__ = new figur (11,40,"blau")
blau2.__proto__ = new figur (11,40,"blau")
blau3.__proto__ = new figur (11,40,"blau")
blau4.__proto__ = new figur (11,40,"blau")
rot1.__proto__ = new figur (1,40,"rot")
rot2.__proto__ = new figur (1,40,"rot")
rot3.__proto__ = new figur (1,40,"rot")
rot4.__proto__ = new figur (1,40,"rot")
gelb1.__proto__ = new figur (31,40,"gelb")
gelb2.__proto__ = new figur (31,40,"gelb")
gelb3.__proto__ = new figur (31,40,"gelb")
gelb4.__proto__ = new figur (31,40,"gelb")
gruen1.__proto__ = new figur (21,40,"gruen")
gruen2.__proto__ = new figur (21,40,"gruen")
gruen3.__proto__ = new figur (21,40,"gruen")
gruen4.__proto__ = new figur (21,40,"gruen")