Ejemplo n.º 1
0
    private void InitMapObject(MapObject mapObject)
    {
        mapObject.Init();

        IAttribute[] attributes = new IAttribute[]
        {
            new MapObjectAttribute(),
            new MapObjectArtAttribute(),
        };

        for (int index = 0; index < attributes.Length; index++)
        {
            IAttribute attribute = attributes[index];
            mapObject.AddAttribute(attribute.GetType().Name, attribute);
        }
    }
Ejemplo n.º 2
0
    public MapObject CreateBullet(Vector3 position)
    {
        string resPath = GameDefine.Path.Bullet;

        MapObject mapObject = GlobalEnvironment.Instance.Get <MapObjectManager>().InstanceMapObject();

        MapObjectAttribute mapObjectAttribute = mapObject.GetAttribute <MapObjectAttribute>();

        mapObjectAttribute.Hp       = 1;
        mapObjectAttribute.Position = position;

        MapObjectArtAttribute mapObjectArtAttribute = mapObject.GetAttribute <MapObjectArtAttribute>();
        GameObject            gameObject            = PopPool(resPath, false);

        if (gameObject == null)
        {
            gameObject = GlobalEnvironment.Instance.Get <ResourceManager>().Instance(resPath);
            gameObject.transform.SetParent(MapObjctParent.transform);
        }
        MapObjectResPathDict.Add(mapObjectAttribute.Id, resPath);
        mapObjectArtAttribute.gameObject         = gameObject;
        mapObjectArtAttribute.transform          = gameObject.transform;
        mapObjectArtAttribute.transform.position = position;
        mapObjectArtAttribute.MaxSpeed           = 0.002f;

        mapObject.AddAttribute <AttachAttackAttribute>(typeof(AttachAttackAttribute).Name, new AttachAttackAttribute());

        GlobalEnvironment.Instance.Get <DailyManager>().RegisterDailyAction(mapObject, new BulletMoveDailyAction());

        GlobalEnvironment.Instance.Get <RepresentManager>().RegisterMapObject <MoveArtHandle>(mapObject);
        GlobalEnvironment.Instance.Get <RepresentManager>().RegisterMapObject <DeathArtHandle>(mapObject);
        GlobalEnvironment.Instance.Get <RepresentManager>().RegisterMapObject <AttachArtHandle>(mapObject);

        AllMapObjectList.Add(mapObject);

        return(mapObject);
    }