PDA

View Full Version : teacher looking for?


Fer912
05-28-2012, 05:27 PM
good morning again to see if someone can lend a hand, I created a mission style coop, which still could not test and so the code is not okay.
My intention is to bring together in an array all the local pilots and remote mission, I wonder if there is any advice on what is written or modified to improve it or fix it thanks

using System;
using System.Collections.Generic;
using maddox.core;
using maddox.game;
using maddox.game.world;
using maddox.GP;



public class Mission : AMission
{

bool _WonSup = true; // wonSup se da con el 75% de los pilotos vivos, cada avion volable vale 12.5
bool _WonEsc = true; // wonEsc se da con el +50% de los aviones de ataques vivos
bool _WonATK = false; // wonATK se da con +60% de los blancos asignados destruidos
int indice = 0;

private class piloto
{
string _nombre;
string _estado;
int _valor;

public string Nombre
{
set { this._nombre = value; }
get { return this._nombre; }
}

public string Estado
{
get { return this._estado; }
set { this._estado = value; }
}

public int Valor
{
set { this._valor = value; }
get { return this._valor; }
}
};

piloto[] p = new piloto[8];

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("WonEsc".Equals(shortName) && active)
{
_WonEsc = false;
GamePlay.gpGetTrigger("WonEsc").Enable = false;
GamePlay.gpHUDLogCenter("WonEsc Fallido");
}

if ("WonAtk".Equals(shortName) && active)
{
_WonATK = true;
GamePlay.gpGetTrigger("WonAtk").Enable = false;
GamePlay.gpHUDLogCenter("WonAtk Cumplido");
}
}


public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
for (int i = 0; i < (actor as AiAircraft).Places(); i++ )
{
if ((actor as AiAircraft).Player(i) != null)
{
p[indice].Nombre = (actor as AiAircraft).Player(i).Name();
p[indice].Estado = "Vivo";
p[indice].Valor = 0; //por ahora no lo uso, va a ser implementado en otros para los defectos del avion segun las tirada de dados de rol
indice++;
}
}
}
}


public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> damages)
{
base.OnActorDead(missionNumber, shortName, actor, damages);

if (actor is AiAircraft)
{
GamePlay.gpLogServer(null, " Paso 1 Ok ", null);

for (int i = 0; i < (actor as AiAircraft).Places(); i++)
{
GamePlay.gpLogServer(null, "Primer For i={0}", new object[] { i });
GamePlay.gpLogServer(null, " Paso 2 Ok ", null);
// if ((actor as AiAircraft).Player(i) != null)
//{
for (int j = 0; j < indice; j++)
{
GamePlay.gpLogServer(null, " Buscando al Piloto Ok ", null);
if (p[j].Nombre.Equals((actor as AiAircraft).Player(i).Name()))
{
p[j].Estado = "Muerto";

GamePlay.gpLogServer(null, "piloto {0} ha muerto JAJAJ", new object[] { p[j].Nombre });
}

}
//}
}
}
}
}

FG28_Kodiak
05-28-2012, 06:29 PM
Sorry i don't understand your question.

Do you want all Players in an Array?

public Player[] AllPlayers()
{
List<Player> players = new List<Player>();

if (GamePlay.gpPlayer() != null)
players.Add(GamePlay.gpPlayer());
if (GamePlay.gpRemotePlayers() != null)
players.AddRange(GamePlay.gpRemotePlayers());

return players.ToArray();
}

I don't understand what you mean with "remote mission".

Fer912
05-28-2012, 07:30 PM
if that kodiak thanks again.
what I wanted to know is if this form is well done or not

public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);

if (actor is AiAircraft)
{
for (int i = 0; i < (actor as AiAircraft).Places(); i++ )
{
if ((actor as AiAircraft).Player(i) != null)
{
p[indice].Nombre = (actor as AiAircraft).Player(i).Name();
p[indice].Estado = "Vivo";
p[indice].Valor = 0; //por ahora no lo uso, va a ser implementado en otros para los defectos del avion segun las tirada de dados de rol
indice++;
}
}
}
}

I apologize for the inconvenience and misunderstanding, my English is very poor as well as my knowledge of programming, so I'm asking and reading everything I can to solve my doubts

mains to thank

FG28_Kodiak
05-28-2012, 08:43 PM
Ah ok, now i understand.

At event OnActorCreated is no human player available. There only 'empty' actors are created.

A Player enters a plane (actor) with the OnPlaceEnter event:

public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);

//your code here
}

Fer912
05-28-2012, 09:16 PM
ok thanks again